#include <map>
#include <ext/mt_allocator.h>
#include <ext/pool_allocator.h>
typedef std::map<ulong, int> Mymap;
//typedef __gnu_cxx::__mt_alloc<unsigned char> allocator_type; //2 n 2
typedef __gnu_cxx::__pool_alloc<unsigned char> allocator_type; //no free to os
static allocator_type aa;
static Mymap ma;
void* am_malloc(size_t size)
{
//mutex
unsigned char* b = aa.allocate(size);
ma.insert(Mymap::value_type((ulong)b, size));
return b;
}
void am_free(void* ptr)
{
//mutex
if (ptr != 0) {
int si = ma.at((ulong)ptr);
aa.deallocate((unsigned char*)ptr, si);
ma.erase((ulong)ptr);
}
}
__gnu_cxx::array_allocator