mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 18:34:13 +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
|
#ifndef mdbx_memalign_alloc
|
||||||
MDBX_INTERNAL_FUNC int mdbx_memalign_alloc(size_t alignment, size_t bytes,
|
MDBX_INTERNAL_FUNC int mdbx_memalign_alloc(size_t alignment, size_t bytes,
|
||||||
void **result) {
|
void **result) {
|
||||||
|
assert(is_powerof2(alignment) && alignment >= sizeof(void *));
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
(void)alignment;
|
(void)alignment;
|
||||||
*result = VirtualAlloc(NULL, bytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
*result = VirtualAlloc(NULL, bytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||||
return *result ? MDBX_SUCCESS : MDBX_ENOMEM /* ERROR_OUTOFMEMORY */;
|
return *result ? MDBX_SUCCESS : MDBX_ENOMEM /* ERROR_OUTOFMEMORY */;
|
||||||
#elif defined(_ISOC11_SOURCE)
|
#elif defined(_ISOC11_SOURCE)
|
||||||
*result = aligned_alloc(alignment, bytes);
|
*result = aligned_alloc(alignment, roundup_powerof2(bytes, alignment));
|
||||||
return *result ? MDBX_SUCCESS : errno;
|
return *result ? MDBX_SUCCESS : errno;
|
||||||
#elif _POSIX_VERSION >= 200112L
|
#elif _POSIX_VERSION >= 200112L
|
||||||
*result = nullptr;
|
*result = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user