Add 'recalloc' replacement

Added recalloc. _expand should be replaced as well in the nearby future. The functions should override the _xxxx_base variants instead, and be moved to a separate lib to cover the executable globally.
This commit is contained in:
Kawe Mazidjatari 2023-06-27 21:37:15 +02:00
parent 48d81d2369
commit 84e3414d7c
2 changed files with 12 additions and 0 deletions

View File

@ -86,6 +86,17 @@ extern "C" void* R_calloc(size_t nCount, size_t nSize)
return pNew;
}
extern "C" void* R_recalloc(void* pBlock, size_t nSize)
{
InitAllocator();
void* pMemOut = MemAllocSingleton()->Realloc(pBlock, nSize);
if (!pBlock)
memset(pMemOut, NULL, nSize);
return pMemOut;
}
extern "C" size_t R_mallocsize(void* pBlock)
{

View File

@ -14,6 +14,7 @@ extern "C" size_t R_mallocsize(void* pBlock);
#define realloc(pBlock, nSize) R_realloc(pBlock, nSize)
#define strdup(pString) R_strdup(pString)
#define calloc(nCount, nSize) R_calloc(nCount, nSize)
#define recalloc(pBlock, nSize) R_recalloc(pBlock, nSize)
#define mallocsize(pBlock) R_mallocsize(pBlock)
class IMemAlloc