diff options
Diffstat (limited to 'serverboot/kalloc.c')
-rw-r--r-- | serverboot/kalloc.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/serverboot/kalloc.c b/serverboot/kalloc.c index 80438738..28c0b55e 100644 --- a/serverboot/kalloc.c +++ b/serverboot/kalloc.c @@ -34,6 +34,14 @@ #include <mach.h> #include <cthreads.h> /* for spin locks */ +#include <malloc.h> /* for malloc_hook/free_hook */ + +static void init_hook (void); +static void *malloc_hook (size_t size, const void *caller); +static void free_hook (void *ptr, const void *caller); + +void (*__malloc_initialize_hook) (void) = init_hook; + #define DEBUG @@ -250,12 +258,21 @@ kfree( void *data, } } -void *malloc(vm_size_t size) +static void +init_hook (void) +{ + __malloc_hook = malloc_hook; + __free_hook = free_hook; +} + +static void * +malloc_hook (size_t size, const void *caller) { - return (void *)kalloc(size); + return (void *) kalloc ((vm_size_t) size); } -void free(void *addr) +static void +free_hook (void *ptr, const void *caller) { /* Just ignore harmless attempts at cleanliness. */ /* panic("free not implemented"); */ |