mirror of
https://github.com/isar/libmdbx.git
synced 2025-02-01 06:48:21 +08:00
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:
parent
ace3d1bfa3
commit
9fae7f92d6
13
src/osal.h
13
src/osal.h
@ -84,6 +84,16 @@ typedef struct {
|
|||||||
HANDLE event;
|
HANDLE event;
|
||||||
} mdbx_condmutex_t;
|
} mdbx_condmutex_t;
|
||||||
typedef CRITICAL_SECTION mdbx_fastmutex_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
|
#else
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@ -103,12 +113,11 @@ typedef struct {
|
|||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
} mdbx_condmutex_t;
|
} mdbx_condmutex_t;
|
||||||
typedef pthread_mutex_t mdbx_fastmutex_t;
|
typedef pthread_mutex_t mdbx_fastmutex_t;
|
||||||
#endif /* Platform */
|
|
||||||
|
|
||||||
#define mdbx_malloc malloc
|
#define mdbx_malloc malloc
|
||||||
#define mdbx_calloc calloc
|
#define mdbx_calloc calloc
|
||||||
#define mdbx_realloc realloc
|
#define mdbx_realloc realloc
|
||||||
#define mdbx_free free
|
#define mdbx_free free
|
||||||
|
#endif /* Platform */
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user