diff --git a/src/osal.c b/src/osal.c index 3a652466..c6ae5d8f 100644 --- a/src/osal.c +++ b/src/osal.c @@ -262,8 +262,9 @@ int mdbx_asprintf(char **strp, const char *fmt, ...) { #ifndef mdbx_memalign_alloc int mdbx_memalign_alloc(size_t alignment, size_t bytes, void **result) { -#if _MSC_VER - *result = _aligned_malloc(bytes, alignment); +#if defined(_WIN32) || defined(_WIN64) + (void)alignment; + *result = VirtualAlloc(NULL, bytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); return *result ? MDBX_SUCCESS : MDBX_ENOMEM /* ERROR_OUTOFMEMORY */; #elif __GLIBC_PREREQ(2, 16) || __STDC_VERSION__ >= 201112L *result = memalign(alignment, bytes); @@ -279,8 +280,8 @@ int mdbx_memalign_alloc(size_t alignment, size_t bytes, void **result) { #ifndef mdbx_memalign_free void mdbx_memalign_free(void *ptr) { -#if _MSC_VER - _aligned_free(ptr); +#if defined(_WIN32) || defined(_WIN64) + VirtualFree(ptr, 0, MEM_RELEASE); #else mdbx_free(ptr); #endif diff --git a/src/osal.h b/src/osal.h index e5c48f7c..8a2abc3b 100644 --- a/src/osal.h +++ b/src/osal.h @@ -439,8 +439,12 @@ static __inline int mdbx_get_errno(void) { return rc; } +#ifndef mdbx_memalign_alloc int mdbx_memalign_alloc(size_t alignment, size_t bytes, void **result); +#endif +#ifndef mdbx_memalign_free void mdbx_memalign_free(void *ptr); +#endif int mdbx_condmutex_init(mdbx_condmutex_t *condmutex); int mdbx_condmutex_lock(mdbx_condmutex_t *condmutex);