HLTBUFFER nr_CreateSurface(int width, int height) { NullBuf *pBuf; LT_MEM_TRACK_ALLOC(pBuf = (NullBuf*)LTMemAlloc(sizeof(NullBuf) + ((width*height)-1) * sizeof(unsigned short)),LT_MEM_TYPE_RENDERER); if(pBuf) { pBuf->m_Width = width; pBuf->m_Height = height; return (HLTBUFFER)pBuf; } else { return LTNULL; } }
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; }
HRENDERCONTEXT nr_CreateContext() { HRENDERCONTEXT p; LT_MEM_TRACK_ALLOC(p = (HRENDERCONTEXT)LTMemAlloc(1),LT_MEM_TYPE_RENDERER); return p; }