void* DefaultAllocator::AllocDebug(size_t size, const char* file, unsigned line) { void* p; #if defined(OVR_CC_MSVC) && defined(_CRTDBG_MAP_ALLOC) p = _malloc_dbg(size, _NORMAL_BLOCK, file, line); #else OVR_UNUSED2(file, line); // should be here for debugopt config p = malloc(size); #endif trackAlloc(p, size); return p; }
void* DefaultAllocator::Alloc(size_t size) { OVR_ALLOC_BENCHMARK_START(); #ifdef OVR_USE_JEMALLOC void* p = je_malloc(size); #else // OVR_USE_JEMALLOC void* p = malloc(size); #endif // OVR_USE_JEMALLOC OVR_ALLOC_BENCHMARK_END(); trackAlloc(p, size); return p; }
void* DefaultAllocator::Realloc(void* p, size_t newSize) { void* newP = realloc(p, newSize); // This used to more efficiently check if (newp != p) but static analyzers were erroneously flagging this. if (newP) // Need to check newP because realloc doesn't free p unless it returns a valid newP. { #if !defined(__clang_analyzer__) // The analyzer complains that we are using p after it was freed. untrackAlloc(p); #endif } trackAlloc(newP, newSize); return newP; }
void* DefaultAllocator::Alloc(size_t size) { void* p = malloc(size); trackAlloc(p, size); return p; }