6 #include "TrackingAllocator.h"
7 #include "AllocationRecord.h"
19 virtual void* Alloc (
size_t alignment,
size_t size,
const char* file,
int line) { (void)alignment; (void)size; (void)file; (void)line;
return NULL; }
20 virtual void Free (
void* data ) { (void)data; }
39 #if defined(Eegeo_MEMORY_TRACKING_NEW)
40 virtual void* Alloc(
size_t alignment,
size_t size,
const char* file,
int line)
42 void* payload = TrackingAllocator::PerformAlloc((
int)alignment, size);
44 record->site.file = file;
45 record->site.line = line;
49 #elif defined (EEGEO_IOS)
50 virtual void* Alloc (
size_t alignment,
size_t size,
const char* file,
int line ) {
void* pData; posix_memalign(&pData, alignment, size);
return pData; }
51 #elif defined (EEGEO_OSX) || defined (EEGEO_WIN)
52 virtual void* Alloc(
size_t alignment,
size_t size,
const char* file,
int line )
54 void *mem = malloc( size );
55 Eegeo_ASSERT(mem != NULL,
"Memory allocation failed!");
59 virtual void* Alloc (
size_t alignment,
size_t size,
const char* file,
int line ) {
void* pData = memalign(alignment, size);
return pData; }
62 #if defined(Eegeo_MEMORY_TRACKING_NEW)
63 virtual void Free(
void* data)
65 TrackingAllocator::PerformFree(data);
68 virtual void Free (
void* data ) { free(data); }
80 #define Eegeo_BASE_ALLOC(alloc, align, size) alloc->Alloc(align, size, __FILE__, __LINE__)
81 #define Eegeo_BASE_FREE(alloc, data) alloc->Free(data)