9 #define MDEBUG(...) printf(__VA_ARGS__)
11 #define MDEBUG(...) do {} while (0)
17 * with MUCH thanks to http://www.parashift.com/c++-faq-lite/memory-pools.html
19 * test framework at https://gist.github.com/triffid/5563987
25 MemoryPool(void* base
, uint16_t size
);
29 void dealloc(void* p
);
31 void debug(StreamOutput
*);
39 static MemoryPool
* first
;
46 // this overloads "placement new"
47 inline void* operator new(size_t nbytes
, MemoryPool
& pool
)
49 return pool
.alloc(nbytes
);
52 // this allows placement new to free memory if the constructor fails
53 inline void operator delete(void* p
, MemoryPool
& pool
)
58 #endif /* _MEMORYPOOL_H */