From eb13c95345799f42ab8916faa682864f6b7463b1 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 14 Mar 2006 23:34:24 +0000 Subject: 2006-03-15 Alfred M. Szmidt * kalloc.c: #include . (init_hook, malloc_hook, free_hook): New functions. (__malloc_initialize_hook): New variable. (malloc, free): Functions removed. --- serverboot/ChangeLog | 7 +++++++ serverboot/kalloc.c | 23 ++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'serverboot') diff --git a/serverboot/ChangeLog b/serverboot/ChangeLog index e532d2a7..f0997fc5 100644 --- a/serverboot/ChangeLog +++ b/serverboot/ChangeLog @@ -1,3 +1,10 @@ +2006-03-15 Alfred M. Szmidt + + * kalloc.c: #include . + (init_hook, malloc_hook, free_hook): New functions. + (__malloc_initialize_hook): New variable. + (malloc, free): Functions removed. + 2003-05-07 Ognyan Kulev * strfcns.c: #include instead of . 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 #include /* for spin locks */ +#include /* 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"); */ -- cgit v1.2.3