mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-30 03:24:13 +08:00
mdbx-windows: use Heap-functions instead of LocalAlloc/LocalFree.
Change-Id: I85f8a4c888bf98f4792f2a5e522d24ee671f060c
This commit is contained in:
parent
161b00a4b6
commit
0054f5388a
18
src/osal.h
18
src/osal.h
@ -166,34 +166,40 @@ typedef struct {
|
|||||||
typedef CRITICAL_SECTION mdbx_fastmutex_t;
|
typedef CRITICAL_SECTION mdbx_fastmutex_t;
|
||||||
|
|
||||||
#if MDBX_WITHOUT_MSVC_CRT
|
#if MDBX_WITHOUT_MSVC_CRT
|
||||||
|
|
||||||
#ifndef mdbx_malloc
|
#ifndef mdbx_malloc
|
||||||
static inline void *mdbx_malloc(size_t bytes) {
|
static inline void *mdbx_malloc(size_t bytes) {
|
||||||
return LocalAlloc(LMEM_FIXED, bytes);
|
return HeapAlloc(GetProcessHeap(), 0, bytes);
|
||||||
}
|
}
|
||||||
#endif /* mdbx_malloc */
|
#endif /* mdbx_malloc */
|
||||||
|
|
||||||
#ifndef mdbx_calloc
|
#ifndef mdbx_calloc
|
||||||
static inline void *mdbx_calloc(size_t nelem, size_t size) {
|
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 */
|
#endif /* mdbx_calloc */
|
||||||
|
|
||||||
#ifndef mdbx_realloc
|
#ifndef mdbx_realloc
|
||||||
static inline void *mdbx_realloc(void *ptr, size_t bytes) {
|
static inline void *mdbx_realloc(void *ptr, size_t bytes) {
|
||||||
return ptr ? LocalReAlloc(ptr, bytes, LMEM_MOVEABLE)
|
return ptr ? HeapReAlloc(GetProcessHeap(), 0, ptr, bytes)
|
||||||
: LocalAlloc(LMEM_FIXED, bytes);
|
: HeapAlloc(GetProcessHeap(), 0, bytes);
|
||||||
}
|
}
|
||||||
#endif /* mdbx_realloc */
|
#endif /* mdbx_realloc */
|
||||||
|
|
||||||
#ifndef mdbx_free
|
#ifndef mdbx_free
|
||||||
#define mdbx_free LocalFree
|
static inline void mdbx_free(void *ptr) {
|
||||||
|
return HeapFree(GetProcessHeap(), 0, ptr);
|
||||||
|
}
|
||||||
#endif /* mdbx_free */
|
#endif /* mdbx_free */
|
||||||
#else
|
|
||||||
|
#else /* MDBX_WITHOUT_MSVC_CRT */
|
||||||
|
|
||||||
#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
|
||||||
#define mdbx_strdup _strdup
|
#define mdbx_strdup _strdup
|
||||||
|
|
||||||
#endif /* MDBX_WITHOUT_MSVC_CRT */
|
#endif /* MDBX_WITHOUT_MSVC_CRT */
|
||||||
|
|
||||||
#ifndef snprintf
|
#ifndef snprintf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user