summaryrefslogtreecommitdiff
path: root/include/mimalloc-internal.h
diff options
context:
space:
mode:
authordaan <daanl@outlook.com>2019-10-30 15:19:34 -0700
committerdaan <daanl@outlook.com>2019-10-30 15:19:34 -0700
commitb73beede344aa8c73bc0606162fece30b51fba46 (patch)
treec5f54e7e5868e0ab42aa2b93f621416e60868429 /include/mimalloc-internal.h
parent9d4f57abf3993def9eed0bf2b07b66c144b6583c (diff)
parent4a4d74927ccd7c07e68d28ca372c6c30408ad92f (diff)
merge from dev
Diffstat (limited to 'include/mimalloc-internal.h')
-rw-r--r--include/mimalloc-internal.h23
1 files changed, 11 insertions, 12 deletions
diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h
index 8d6cc29..f4822b1 100644
--- a/include/mimalloc-internal.h
+++ b/include/mimalloc-internal.h
@@ -415,7 +415,7 @@ static inline bool mi_is_in_same_segment(const void* p, const void* q) {
}
static inline mi_block_t* mi_block_nextx( uintptr_t cookie, const mi_block_t* block ) {
- #if MI_SECURE
+ #ifdef MI_ENCODE_FREELIST
return (mi_block_t*)(block->next ^ cookie);
#else
UNUSED(cookie);
@@ -424,7 +424,7 @@ static inline mi_block_t* mi_block_nextx( uintptr_t cookie, const mi_block_t* bl
}
static inline void mi_block_set_nextx(uintptr_t cookie, mi_block_t* block, const mi_block_t* next) {
- #if MI_SECURE
+ #ifdef MI_ENCODE_FREELIST
block->next = (mi_encoded_t)next ^ cookie;
#else
UNUSED(cookie);
@@ -433,16 +433,15 @@ static inline void mi_block_set_nextx(uintptr_t cookie, mi_block_t* block, const
}
static inline mi_block_t* mi_block_next(const mi_page_t* page, const mi_block_t* block) {
- #if MI_SECURE
+ #ifdef MI_ENCODE_FREELIST
mi_block_t* next = mi_block_nextx(page->cookie,block);
- #if MI_SECURE >= 4
- // check if next is at least in our segment range
- // TODO: it is better to check if it is actually inside our page but that is more expensive
- // to calculate. Perhaps with a relative free list this becomes feasible?
- if (next!=NULL && !mi_is_in_same_segment(block, next)) {
- _mi_fatal_error("corrupted free list entry at %p: %zx\n", block, (uintptr_t)next);
- }
- #endif
+ // check for free list corruption: is `next` at least in our segment range?
+ // TODO: it is better to check if it is actually inside our page but that is more expensive
+ // to calculate. Perhaps with a relative free list this becomes feasible?
+ if (next!=NULL && !mi_is_in_same_segment(block, next)) {
+ _mi_fatal_error("corrupted free list entry of size %zub at %p: value 0x%zx\n", page->block_size, block, (uintptr_t)next);
+ next = NULL;
+ }
return next;
#else
UNUSED(page);
@@ -451,7 +450,7 @@ static inline mi_block_t* mi_block_next(const mi_page_t* page, const mi_block_t*
}
static inline void mi_block_set_next(const mi_page_t* page, mi_block_t* block, const mi_block_t* next) {
- #if MI_SECURE
+ #ifdef MI_ENCODE_FREELIST
mi_block_set_nextx(page->cookie,block,next);
#else
UNUSED(page);