mdbx: allow pre-define mdbx_malloc/mdbx_free macros.

Related to https://github.com/leo-yuriev/libmdbx/issues/43#issuecomment-429625047

Change-Id: Icaee4ba62003e6eacef9f938bdea19426623b5da
This commit is contained in:
Leonid Yuriev 2018-10-14 18:44:22 +03:00
parent 30a80ff07c
commit d2bfb2e489

View File

@ -90,19 +90,39 @@ typedef struct {
HANDLE event;
} mdbx_condmutex_t;
typedef CRITICAL_SECTION mdbx_fastmutex_t;
#ifndef mdbx_malloc
static inline void *mdbx_malloc(size_t bytes) {
return LocalAlloc(LMEM_FIXED, 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);
}
#endif /* mdbx_calloc */
#ifndef mdbx_realloc
static inline void *mdbx_realloc(void *ptr, size_t bytes) {
return LocalReAlloc(ptr, bytes, LMEM_MOVEABLE);
}
#endif /* mdbx_realloc */
#ifndef mdbx_free
#define mdbx_free LocalFree
#define snprintf _snprintf /* ntdll */
#endif /* mdbx_free */
#ifndef snprintf
#define snprintf _snprintf /* ntdll */
#endif
#ifndef vsnprintf
#define vsnprintf _vsnprintf /* ntdll */
#else
#endif
#else /*----------------------------------------------------------------------*/
#include <pthread.h>
#include <signal.h>
#include <sys/file.h>