mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-26 19:33:31 +00:00
[MSVCRTEX] Add recalloc. CORE-20596
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user