set extra debug padding per-heap

This commit is contained in:
daan 2020-04-20 17:09:28 -07:00
parent ae608cda2f
commit 9ebb94fe17
10 changed files with 65 additions and 49 deletions

View file

@ -16,7 +16,7 @@ static void dangling_ptr_write();
int main() {
mi_version();
mi_heap_set_extra_padding(mi_heap_get_default(), 200);
// detect double frees and heap corruption
// double_free1();
// double_free2();

View file

@ -153,7 +153,10 @@ int main() {
result = ok;
});
CHECK_BODY("malloc-aligned5", {
void* p = mi_malloc_aligned(4097,4096); size_t usable = mi_usable_size(p); result = usable >= 4097 && usable < 10000; mi_free(p);
void* p = mi_malloc_aligned(4097,4096);
size_t usable = mi_usable_size(p);
result = (usable >= 4097 && usable < 12000 && ((uintptr_t)p % 4096) == 0);
mi_free(p);
});
CHECK_BODY("malloc-aligned-at1", {
void* p = mi_malloc_aligned_at(48,32,0); result = (p != NULL && ((uintptr_t)(p) + 0) % 32 == 0); mi_free(p);