From 306ee9d36ef89f3e5fae293038e521b94a802b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 27 Sep 2023 17:24:00 +0200 Subject: [PATCH] [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. --- dll/win32/setupapi/setupapi_private.h | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/dll/win32/setupapi/setupapi_private.h b/dll/win32/setupapi/setupapi_private.h index b3084e8a1b9..7547dc4c0d6 100644 --- a/dll/win32/setupapi/setupapi_private.h +++ b/dll/win32/setupapi/setupapi_private.h @@ -58,7 +58,35 @@ WINE_DEFAULT_DEBUG_CHANNEL(setupapi); #endif #ifdef __REACTOS__ + #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) + +#include +// 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