mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-15 22:44:29 +08:00
mdbx: макрос osal_malloc_usable_size()
вместо непосредственного использования malloc_usable_size()
.
This commit is contained in:
parent
5168c80be8
commit
4607184999
@ -41,9 +41,9 @@ dpl_t *dpl_reserve(MDBX_txn *txn, size_t size) {
|
|||||||
size_t bytes = dpl_size2bytes((size < PAGELIST_LIMIT) ? size : PAGELIST_LIMIT);
|
size_t bytes = dpl_size2bytes((size < PAGELIST_LIMIT) ? size : PAGELIST_LIMIT);
|
||||||
dpl_t *const dl = osal_realloc(txn->tw.dirtylist, bytes);
|
dpl_t *const dl = osal_realloc(txn->tw.dirtylist, bytes);
|
||||||
if (likely(dl)) {
|
if (likely(dl)) {
|
||||||
#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size)
|
#ifdef osal_malloc_usable_size
|
||||||
bytes = malloc_usable_size(dl);
|
bytes = osal_malloc_usable_size(dl);
|
||||||
#endif /* malloc_usable_size */
|
#endif /* osal_malloc_usable_size */
|
||||||
dl->detent = dpl_bytes2size(bytes);
|
dl->detent = dpl_bytes2size(bytes);
|
||||||
tASSERT(txn, txn->tw.dirtylist == nullptr || dl->length <= dl->detent);
|
tASSERT(txn, txn->tw.dirtylist == nullptr || dl->length <= dl->detent);
|
||||||
txn->tw.dirtylist = dl;
|
txn->tw.dirtylist = dl;
|
||||||
|
@ -153,12 +153,12 @@ typedef pthread_mutex_t osal_fastmutex_t;
|
|||||||
#endif /* Platform */
|
#endif /* Platform */
|
||||||
|
|
||||||
#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size)
|
#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size)
|
||||||
/* malloc_usable_size() already provided */
|
#define osal_malloc_usable_size(ptr) malloc_usable_size(ptr)
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#define malloc_usable_size(ptr) malloc_size(ptr)
|
#define osal_malloc_usable_size(ptr) malloc_size(ptr)
|
||||||
#elif defined(_MSC_VER) && !MDBX_WITHOUT_MSVC_CRT
|
#elif defined(_MSC_VER) && !MDBX_WITHOUT_MSVC_CRT
|
||||||
#define malloc_usable_size(ptr) _msize(ptr)
|
#define osal_malloc_usable_size(ptr) _msize(ptr)
|
||||||
#endif /* malloc_usable_size */
|
#endif /* osal_malloc_usable_size */
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* OS abstraction layer stuff */
|
/* OS abstraction layer stuff */
|
||||||
|
18
src/pnl.c
18
src/pnl.c
@ -7,9 +7,9 @@ MDBX_INTERNAL pnl_t pnl_alloc(size_t size) {
|
|||||||
size_t bytes = pnl_size2bytes(size);
|
size_t bytes = pnl_size2bytes(size);
|
||||||
pnl_t pnl = osal_malloc(bytes);
|
pnl_t pnl = osal_malloc(bytes);
|
||||||
if (likely(pnl)) {
|
if (likely(pnl)) {
|
||||||
#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size)
|
#ifdef osal_malloc_usable_size
|
||||||
bytes = malloc_usable_size(pnl);
|
bytes = osal_malloc_usable_size(pnl);
|
||||||
#endif /* malloc_usable_size */
|
#endif /* osal_malloc_usable_size */
|
||||||
pnl[0] = pnl_bytes2size(bytes);
|
pnl[0] = pnl_bytes2size(bytes);
|
||||||
assert(pnl[0] >= size);
|
assert(pnl[0] >= size);
|
||||||
pnl += 1;
|
pnl += 1;
|
||||||
@ -33,9 +33,9 @@ MDBX_INTERNAL void pnl_shrink(pnl_t __restrict *__restrict ppnl) {
|
|||||||
size_t bytes = pnl_size2bytes(MDBX_PNL_INITIAL * 2);
|
size_t bytes = pnl_size2bytes(MDBX_PNL_INITIAL * 2);
|
||||||
pnl_t pnl = osal_realloc(*ppnl - 1, bytes);
|
pnl_t pnl = osal_realloc(*ppnl - 1, bytes);
|
||||||
if (likely(pnl)) {
|
if (likely(pnl)) {
|
||||||
#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size)
|
#ifdef osal_malloc_usable_size
|
||||||
bytes = malloc_usable_size(pnl);
|
bytes = osal_malloc_usable_size(pnl);
|
||||||
#endif /* malloc_usable_size */
|
#endif /* osal_malloc_usable_size */
|
||||||
*pnl = pnl_bytes2size(bytes);
|
*pnl = pnl_bytes2size(bytes);
|
||||||
*ppnl = pnl + 1;
|
*ppnl = pnl + 1;
|
||||||
}
|
}
|
||||||
@ -57,9 +57,9 @@ MDBX_INTERNAL int pnl_reserve(pnl_t __restrict *__restrict ppnl, const size_t wa
|
|||||||
size_t bytes = pnl_size2bytes(size);
|
size_t bytes = pnl_size2bytes(size);
|
||||||
pnl_t pnl = osal_realloc(*ppnl - 1, bytes);
|
pnl_t pnl = osal_realloc(*ppnl - 1, bytes);
|
||||||
if (likely(pnl)) {
|
if (likely(pnl)) {
|
||||||
#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size)
|
#ifdef osal_malloc_usable_size
|
||||||
bytes = malloc_usable_size(pnl);
|
bytes = osal_malloc_usable_size(pnl);
|
||||||
#endif /* malloc_usable_size */
|
#endif /* osal_malloc_usable_size */
|
||||||
*pnl = pnl_bytes2size(bytes);
|
*pnl = pnl_bytes2size(bytes);
|
||||||
assert(*pnl >= wanna);
|
assert(*pnl >= wanna);
|
||||||
*ppnl = pnl + 1;
|
*ppnl = pnl + 1;
|
||||||
|
12
src/txl.c
12
src/txl.c
@ -21,9 +21,9 @@ MDBX_INTERNAL txl_t txl_alloc(void) {
|
|||||||
size_t bytes = txl_size2bytes(txl_initial);
|
size_t bytes = txl_size2bytes(txl_initial);
|
||||||
txl_t txl = osal_malloc(bytes);
|
txl_t txl = osal_malloc(bytes);
|
||||||
if (likely(txl)) {
|
if (likely(txl)) {
|
||||||
#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size)
|
#ifdef osal_malloc_usable_size
|
||||||
bytes = malloc_usable_size(txl);
|
bytes = osal_malloc_usable_size(txl);
|
||||||
#endif /* malloc_usable_size */
|
#endif /* osal_malloc_usable_size */
|
||||||
txl[0] = txl_bytes2size(bytes);
|
txl[0] = txl_bytes2size(bytes);
|
||||||
assert(txl[0] >= txl_initial);
|
assert(txl[0] >= txl_initial);
|
||||||
txl += 1;
|
txl += 1;
|
||||||
@ -52,9 +52,9 @@ MDBX_INTERNAL int txl_reserve(txl_t __restrict *__restrict ptxl, const size_t wa
|
|||||||
size_t bytes = txl_size2bytes(size);
|
size_t bytes = txl_size2bytes(size);
|
||||||
txl_t txl = osal_realloc(*ptxl - 1, bytes);
|
txl_t txl = osal_realloc(*ptxl - 1, bytes);
|
||||||
if (likely(txl)) {
|
if (likely(txl)) {
|
||||||
#if __GLIBC_PREREQ(2, 12) || defined(__FreeBSD__) || defined(malloc_usable_size)
|
#ifdef osal_malloc_usable_size
|
||||||
bytes = malloc_usable_size(txl);
|
bytes = osal_malloc_usable_size(txl);
|
||||||
#endif /* malloc_usable_size */
|
#endif /* osal_malloc_usable_size */
|
||||||
*txl = txl_bytes2size(bytes);
|
*txl = txl_bytes2size(bytes);
|
||||||
assert(*txl >= wanna);
|
assert(*txl >= wanna);
|
||||||
*ptxl = txl + 1;
|
*ptxl = txl + 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user