mdbx-windows: use LocalAlloc/LocalFree instead of CRT's malloc/free.

2 of 17 for https://github.com/leo-yuriev/libmdbx/issues/43

Change-Id: Icb5289b55897d52ac00007f30b36bd84e5a0cbd1
This commit is contained in:
Leonid Yuriev 2018-10-13 11:32:46 +03:00
parent ace3d1bfa3
commit 9fae7f92d6

View File

@ -84,6 +84,16 @@ typedef struct {
HANDLE event;
} mdbx_condmutex_t;
typedef CRITICAL_SECTION mdbx_fastmutex_t;
static inline void *mdbx_malloc(size_t bytes) {
return LocalAlloc(LMEM_FIXED, bytes);
}
static inline void *mdbx_calloc(size_t nelem, size_t size) {
return LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, nelem * size);
}
static inline void *mdbx_realloc(void *ptr, size_t bytes) {
return LocalReAlloc(ptr, bytes, LMEM_MOVEABLE);
}
#define mdbx_free LocalFree
#else
#include <pthread.h>
#include <signal.h>
@ -103,12 +113,11 @@ typedef struct {
pthread_cond_t cond;
} mdbx_condmutex_t;
typedef pthread_mutex_t mdbx_fastmutex_t;
#endif /* Platform */
#define mdbx_malloc malloc
#define mdbx_calloc calloc
#define mdbx_realloc realloc
#define mdbx_free free
#endif /* Platform */
/* *INDENT-OFF* */
/* clang-format off */