void* dalloc(size_t size) { //[DLK] Removed to avoid allocation errors with D3DXEffectCompiler /* if(size == 0) { return NULL; } */ size_t fullAllocSize; // Add 4 bytes if we're tracking memory usage. #ifdef TRACK_MEMORY_USAGE MemTrack *pMemTrack; fullAllocSize = size + sizeof(MemTrack); #else fullAllocSize = size; #endif char *ptr; // Try to allocate the memory. { CountAdder cntAdd(&g_PD_Malloc); LT_MEM_TRACK_ALLOC(ptr = (char*)LTMemAlloc(fullAllocSize),LT_MEM_TYPE_UNKNOWN); } if(!ptr) { dsi_OnMemoryFailure(); } // Store the size in there if we're tracking memory usage. #ifdef TRACK_MEMORY_USAGE g_MemoryUsage += size; pMemTrack = (MemTrack*)ptr; pMemTrack->m_AllocSize = size; pMemTrack->m_AllocNumber = g_nAllocations; ptr += sizeof(MemTrack); #endif ++g_nAllocations; ++g_nTotalAllocations; return ptr; }
void* dalloc(uint32 size) { if(size == 0) return NULL; unsigned long fullAllocSize; // Add 4 bytes if we're tracking memory usage. #ifdef TRACK_MEMORY_USAGE MemTrack *pMemTrack; fullAllocSize = size + sizeof(MemTrack); #else fullAllocSize = size; #endif char *ptr; // Try to allocate the memory. { CountAdder cntAdd(&g_PD_Malloc); LT_MEM_TRACK_ALLOC(ptr = (char*)LTMemAlloc((size_t)fullAllocSize),LT_MEM_TYPE_UNKNOWN); } if(!ptr) { dsi_OnMemoryFailure(); } // Store the size in there if we're tracking memory usage. #ifdef TRACK_MEMORY_USAGE g_MemoryUsage += size; pMemTrack = (MemTrack*)ptr; pMemTrack->m_AllocSize = size; pMemTrack->m_AllocNumber = g_nAllocations; ptr += sizeof(MemTrack); #endif ++g_nAllocations; ++g_nTotalAllocations; return ptr; }
static int dm_NewHandler(size_t size) { dsi_OnMemoryFailure(); return 0; }
static void dm_NewHandler() { dsi_OnMemoryFailure(); }