mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-30 11:29:19 +08:00
mdbx: fix aligned_alloc() usage.
This commit is contained in:
parent
6009bac1ed
commit
62a39d84b3
@ -324,12 +324,13 @@ MDBX_INTERNAL_FUNC int mdbx_asprintf(char **strp, const char *fmt, ...) {
|
||||
#ifndef mdbx_memalign_alloc
|
||||
MDBX_INTERNAL_FUNC int mdbx_memalign_alloc(size_t alignment, size_t bytes,
|
||||
void **result) {
|
||||
assert(is_powerof2(alignment) && alignment >= sizeof(void *));
|
||||
#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 defined(_ISOC11_SOURCE)
|
||||
*result = aligned_alloc(alignment, bytes);
|
||||
*result = aligned_alloc(alignment, roundup_powerof2(bytes, alignment));
|
||||
return *result ? MDBX_SUCCESS : errno;
|
||||
#elif _POSIX_VERSION >= 200112L
|
||||
*result = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user