mirror of
https://github.com/reactos/reactos.git
synced 2025-02-28 19:32:59 +00:00
[SETUPAPI] Add a temporary private implementation of _recalloc.
Needed for the next commit. Code has been copied and adapted from sdk/lib/crt/wine/heap.c. This is because this NT6+ function is not currently exported from MSVCRT.DLL, and it is not possible to static-link parts of the CRT lib while also using the dll.
This commit is contained in:
parent
11d2757e13
commit
306ee9d36e
1 changed files with 28 additions and 0 deletions
|
@ -58,7 +58,35 @@ WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
|
|||
#endif
|
||||
|
||||
#ifdef __REACTOS__
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
|
||||
|
||||
#include <malloc.h>
|
||||
// Redefine _recalloc since the header contains the function definition
|
||||
// as exported from msvcrt.dll, which we do not currently support (NT 6+)
|
||||
#define _recalloc _my_recalloc
|
||||
static inline 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((BYTE*)ret+old_size, 0, size-old_size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#include <setupapi_undoc.h>
|
||||
|
|
Loading…
Reference in a new issue