diff options
author | Anton Korobeynikov <anton@korobeynikov.info> | 2020-04-21 15:10:49 +0300 |
---|---|---|
committer | Anton Korobeynikov <anton@korobeynikov.info> | 2020-04-21 15:10:49 +0300 |
commit | fe976caaea6d208f1c8499bdf5e478f35df6e67e (patch) | |
tree | cbb6ab4471e990f3820536124d1924eb789a383c /src/alloc-override-osx.c | |
parent | 07d72f4fba97c698191a855fdf24efddc4387e74 (diff) |
Provide zone_size function: free() uses it to find the zone pointer belongs to in order to call the corresponding zone_free function
Diffstat (limited to 'src/alloc-override-osx.c')
-rw-r--r-- | src/alloc-override-osx.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/alloc-override-osx.c b/src/alloc-override-osx.c index cc03f5e..c1c880c 100644 --- a/src/alloc-override-osx.c +++ b/src/alloc-override-osx.c @@ -41,8 +41,11 @@ extern malloc_zone_t* malloc_default_purgeable_zone(void) __attribute__((weak_im ------------------------------------------------------ */ static size_t zone_size(malloc_zone_t* zone, const void* p) { - UNUSED(zone); UNUSED(p); - return 0; // as we cannot guarantee that `p` comes from us, just return 0 + UNUSED(zone); + if (!mi_is_in_heap_region(p)) + return 0; // not our pointer, bail out + + return mi_usable_size(p); } static void* zone_malloc(malloc_zone_t* zone, size_t size) { |