6 #ifndef __BLOCKALLOC_H__ 7 #define __BLOCKALLOC_H__ 20 void DebugLog(
wxString cn,
int blockSize,
int poolSize,
int max_refs,
int total_refs,
int ref_count);
27 template <
class T,
unsigned int pool_size, const
bool debug>
48 allocBlocks.push_back(ptr);
50 for(
unsigned int i = 0; i < pool_size - 1; ++i)
51 ptr[i].next = &ptr[i+1];
53 ptr[pool_size - 1].
next = 0;
70 assert(__builtin_constant_p(debug));
77 BlkAllc::DebugLog(
cbC2U(
typeid(T).name()), allocBlocks.size(), pool_size, max_refs, total_refs, ref_count);
79 BlkAllc::DebugLog(
cbC2U(
typeid(T).name()), allocBlocks.size(), pool_size, max_refs, total_refs, ref_count);
81 for(
unsigned int i = 0; i < allocBlocks.size(); ++i)
82 delete[] allocBlocks[i];
91 max_refs = ref_count > max_refs ? ref_count : max_refs;
112 template <
class T,
unsigned int pool_size, const
bool debug = 0>
119 inline void*
operator new(cb_unused
size_t size)
121 return allocator.
New();
124 inline void operator delete(
void *
ptr)
131 template<
class T,
unsigned int pool_size, const
bool debug>
void DebugLog(wxString cn, int blockSize, int poolSize, int max_refs, int total_refs, int ref_count)
DLLIMPORT wxString cbC2U(const char *str)
Return str as a proper unicode-compatible string.
std::vector< LinkedBlock< T > * > allocBlocks
const bool enable_global_debug
void AllocBlockPushBack()
static BlockAllocator< T, pool_size, debug > allocator
const wxString ptr(_T("*"))
void PushFront(LinkedBlock< T > *p)