Free memory properly

This commit is contained in:
Kawe Mazidjatari 2022-08-12 15:45:49 +02:00
parent 52ee409f5f
commit 3b160b6ac6
3 changed files with 9 additions and 10 deletions

View File

@ -251,7 +251,7 @@ void CUtlBlockMemory<T, I>::ChangeSize(int nBlocks)
for (int i = m_nBlocks; i < nBlocksOld; ++i)
{
UTLBLOCKMEMORY_TRACK_FREE();
free((void*)m_pMemory[i]);
MemAllocSingleton()->Free(m_pMemory[i]);
}
if (m_pMemory)
@ -305,12 +305,12 @@ void CUtlBlockMemory<T, I>::Purge()
for (int i = 0; i < m_nBlocks; ++i)
{
UTLBLOCKMEMORY_TRACK_FREE();
free((void*)m_pMemory[i]);
MemAllocSingleton()->Free(m_pMemory[i]);
}
m_nBlocks = 0;
UTLBLOCKMEMORY_TRACK_FREE();
free((void*)m_pMemory);
MemAllocSingleton()->Free(m_pMemory);
m_pMemory = 0;
}

View File

@ -366,7 +366,7 @@ public:
// Memory deallocation
void Purge()
{
free(m_pMemory);
MemAllocSingleton()->Free(m_pMemory);
RememberAllocSize(0);
m_pMemory = NULL;
}
@ -853,7 +853,7 @@ void CUtlMemory<T, I>::Purge()
if (m_pMemory)
{
UTLMEMORY_TRACK_FREE();
free((void*)m_pMemory);
MemAllocSingleton()->Free(m_pMemory);
m_pMemory = 0;
}
m_nAllocationCount = 0;

View File

@ -333,24 +333,23 @@ class CUtlVectorUltraConservativeAllocator
public:
static void* Alloc(size_t nSize)
{
return malloc(nSize);
return MemAllocSingleton()->Alloc<void*>(nSize);
}
static void* Realloc(void* pMem, size_t nSize)
{
return realloc(pMem, nSize);
return MemAllocSingleton()->Realloc(pMem, nSize);
}
static void Free(void* pMem)
{
free(pMem);
MemAllocSingleton()->Free(pMem);
}
static size_t GetSize(void* pMem)
{
return mallocsize(pMem);
return MemAllocSingleton()->GetSize(pMem);
}
};
template <typename T, typename A = CUtlVectorUltraConservativeAllocator >