summaryrefslogtreecommitdiff
path: root/src/alloc-override-osx.c
diff options
context:
space:
mode:
authorDaan <daanl@outlook.com>2021-11-04 18:55:12 -0700
committerDaan <daanl@outlook.com>2021-11-04 18:55:12 -0700
commitc47de7eb9090cf8c0a5f307a74437cf927a361be (patch)
treeb1b59ca81d2ba0cb081391c358bc6c1d296c41cc /src/alloc-override-osx.c
parente853f530a0d90ae49caf17c994a61febbe80230a (diff)
improve macOS overriding
Diffstat (limited to 'src/alloc-override-osx.c')
-rw-r--r--src/alloc-override-osx.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/alloc-override-osx.c b/src/alloc-override-osx.c
index 0759f78..35b95a2 100644
--- a/src/alloc-override-osx.c
+++ b/src/alloc-override-osx.c
@@ -232,13 +232,16 @@ static malloc_zone_t mi_malloc_zone = {
#endif
-#if defined(MI_OSX_INTERPOSE)
+#if defined(MI_OSX_INTERPOSE) && defined(MI_SHARED_LIB_EXPORT)
// ------------------------------------------------------
-// Override malloc_xxx and zone_xxx api's to use only
+// Override malloc_xxx and malloc_zone_xxx api's to use only
// our mimalloc zone. Since even the loader uses malloc
// on macOS, this ensures that all allocations go through
// mimalloc (as all calls are interposed).
+// The main `malloc`, `free`, etc calls are interposed in `alloc-override.c`,
+// Here, we also override macOS specific API's like
+// `malloc_zone_calloc` etc. see <https://github.com/aosm/libmalloc/blob/master/man/malloc_zone_malloc.3>
// ------------------------------------------------------
static inline malloc_zone_t* mi_get_default_zone(void)
@@ -386,6 +389,8 @@ __attribute__((used)) static const struct mi_interpose_s _mi_zone_interposes[]
// ------------------------------------------------------
// hook into the zone api's without interposing
+// This is the official way of adding an allocator but
+// it seems less robust than using interpose.
// ------------------------------------------------------
static inline malloc_zone_t* mi_get_default_zone(void)