[MSVCRTEX] Add recalloc. CORE-20596

This commit is contained in:
Amine Khaldi
2026-07-25 17:41:41 +01:00
parent 360b579a5d
commit b6cb53569d
2 changed files with 34 additions and 1 deletions
+2 -1
View File
@@ -8,7 +8,8 @@ list(APPEND MSVCRTEX_SOURCE
misc/isblank.c
misc/iswblank.c
misc/ofmt_stub.c
stdio/acrt_iob_func.c)
stdio/acrt_iob_func.c
recalloc.c)
if(DLL_EXPORT_VERSION LESS 0x600)
list(APPEND MSVCRTEX_SOURCE
+32
View File
@@ -0,0 +1,32 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <malloc.h>
void* __cdecl recalloc(void *mem, size_t num, size_t size)
{
size_t old_size;
void *ret;
if(!mem)
return calloc(num, size);
size = num*size;
old_size = _msize(mem);
ret = realloc(mem, size);
if(!ret) {
*_errno() = ENOMEM;
return NULL;
}
if(size>old_size)
memset((unsigned char*)ret+old_size, 0, size-old_size);
return ret;
}
#ifdef _WIN64
void* __imp__recalloc = recalloc;
#else
void* _imp___recalloc = recalloc;
#endif