From 0054f5388af8a297f9cd7f1917b23057ad901ac3 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Fri, 30 Apr 2021 02:24:36 +0300 Subject: [PATCH] mdbx-windows: use Heap-functions instead of LocalAlloc/LocalFree. Change-Id: I85f8a4c888bf98f4792f2a5e522d24ee671f060c --- src/osal.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/osal.h b/src/osal.h index 0df98cce..d31a254f 100644 --- a/src/osal.h +++ b/src/osal.h @@ -166,34 +166,40 @@ typedef struct { typedef CRITICAL_SECTION mdbx_fastmutex_t; #if MDBX_WITHOUT_MSVC_CRT + #ifndef mdbx_malloc static inline void *mdbx_malloc(size_t bytes) { - return LocalAlloc(LMEM_FIXED, bytes); + return HeapAlloc(GetProcessHeap(), 0, bytes); } #endif /* mdbx_malloc */ #ifndef mdbx_calloc static inline void *mdbx_calloc(size_t nelem, size_t size) { - return LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, nelem * size); + return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nelem * size); } #endif /* mdbx_calloc */ #ifndef mdbx_realloc static inline void *mdbx_realloc(void *ptr, size_t bytes) { - return ptr ? LocalReAlloc(ptr, bytes, LMEM_MOVEABLE) - : LocalAlloc(LMEM_FIXED, bytes); + return ptr ? HeapReAlloc(GetProcessHeap(), 0, ptr, bytes) + : HeapAlloc(GetProcessHeap(), 0, bytes); } #endif /* mdbx_realloc */ #ifndef mdbx_free -#define mdbx_free LocalFree +static inline void mdbx_free(void *ptr) { + return HeapFree(GetProcessHeap(), 0, ptr); +} #endif /* mdbx_free */ -#else + +#else /* MDBX_WITHOUT_MSVC_CRT */ + #define mdbx_malloc malloc #define mdbx_calloc calloc #define mdbx_realloc realloc #define mdbx_free free #define mdbx_strdup _strdup + #endif /* MDBX_WITHOUT_MSVC_CRT */ #ifndef snprintf