#ifndef Storage_First #define Storage_First #ifdef __GNUG__ #pragma interface #endif #include "Types.h" typedef void (*FreeHookFun)(void*, void *addr, size_t); //---- Pools of fixed size storage allocators ---------------------------------- class Storage { public: static void *ReAlloc(void *vp, size_t sz); // same as realloc but with statistics static void *ObjectAlloc(size_t sz); static void Statistics(); static void SetFreeHook(FreeHookFun, void *data); static void FreeAll(); static void EnableStatistics(int size= -1, int ix= -1); static void *_Malloc(size_t sz); // same as malloc, no statistics static void *_Calloc(int n, size_t sz); // same as calloc, no statistics static void *_Realloc(void *vp, size_t sz); // same as realloc, no statistics static int _Free(void *vp); // same as free, no statistics }; void *operator new(size_t, void*); //---- misc --------------------------------------------------------- #if defined(sun) || defined(sony) # if defined(sparc) && !defined(alloca) # define alloca(x) __builtin_alloca(x) # endif # if !defined(sony) && !defined(__GNUG__) # if defined(sparc) extern "C" char *alloca(int); # else extern "C" void *alloca(size_t); # endif # endif # define Alloca(x) ((void*)alloca(x)) # define Freea(x) #else # define Alloca(x) ((void*)(new char[x])) # define Freea(x) delete (x) #endif #endif