34 #ifndef LIB_DEL_STASH_H 35 #define LIB_DEL_STASH_H 60 typedef void KillFun(
void*);
72 Killer(KillFun* f,
void* t)
87 bool operator== (
const void* target)
const {
return target_ == target; }
88 bool operator!= (
const void* target)
const {
return target_ != target; }
98 typedef std::vector<Killer> Killers;
104 DelStash (
size_t elms_to_reserve =0)
109 killers_.reserve (elms_to_reserve);
119 WARN (memory,
"Problems on de-allocation: %s", errID.c());
126 size_t activeEntries = 0;
127 size_t i = killers_.size();
129 if (killers_[--i].isActive())
131 return activeEntries;
136 template<
typename TY>
141 REQUIRE (!isRegistered (obj));
142 killers_.push_back (
Killer (how_to_kill<TY>, obj));
145 template<
typename TY>
149 REQUIRE (!isRegistered (&obj));
150 killers_.push_back (
Killer (how_to_kill<TY>, &obj));
154 manage (
void* obj, KillFun* customDeleter)
157 REQUIRE (!isRegistered (obj));
158 killers_.push_back (
Killer (customDeleter, obj));
162 template<
typename TY>
170 template<
typename TY>
180 size_t i = killers_.size();
182 killers_[--i].trigger();
193 X* victim =
static_cast<X*
> (subject);
199 isRegistered (
const void* objAddress)
201 REQUIRE (objAddress);
202 return killers_.end() != findEntry (objAddress);
206 findEntry (
const void* obj)
209 return std::find (killers_.begin(),killers_.end(), obj);
213 triggerKill (
void* objAddress)
215 Killers::iterator pos = findEntry (objAddress);
216 if (killers_.end() != pos)
218 ENSURE (!isRegistered (objAddress),
"duplicate deleter registration");
Any copy and copy construction prohibited.
Implementation namespace for support and library code.
Token or Atom with distinct identity.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Marker types to indicate a literal string and a Symbol.
lumiera_err lumiera_error(void)
Get and clear current error state.
Manage a collection of deleter functions.
Lumiera error handling (C++ interface).
static void how_to_kill(void *subject)
trampoline function to invoke destructor of the specific target type