From 406fefafe4af3db81a0129c18edb8bd64c9ef44f Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Mon, 20 Oct 2008 03:30:22 +0000 Subject: [PATCH] was using this for debugging. keep it there for future reference. didn't know we had such malloc hooks! i might consider using these in future! SVN revision: 36831 --- src/bin/e_main.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/bin/e_main.c b/src/bin/e_main.c index e72008c96..0b46ebe04 100644 --- a/src/bin/e_main.c +++ b/src/bin/e_main.c @@ -7,6 +7,53 @@ #include #endif +/* + * i need to make more use of these when i'm baffled as to when something is + * up. other hooks: + * + * void *(*__malloc_hook)(size_t size, const void *caller); + * + * void *(*__realloc_hook)(void *ptr, size_t size, const void *caller); + * + * void *(*__memalign_hook)(size_t alignment, size_t size, + * const void *caller); + * + * void (*__free_hook)(void *ptr, const void *caller); + * + * void (*__malloc_initialize_hook)(void); + * + * void (*__after_morecore_hook)(void); + * + +static void my_init_hook(void); +static void my_free_hook(void *p, const void *caller); + +static void (*old_free_hook)(void *ptr, const void *caller) = NULL; +void (*__free_hook)(void *ptr, const void *caller); + +void (*__malloc_initialize_hook) (void) = my_init_hook; +static void +my_init_hook(void) +{ + old_free_hook = __free_hook; + __free_hook = my_free_hook; +} + +//void *magicfree = NULL; + +static void my_free_hook(void *p, const void *caller) +{ + __free_hook = old_free_hook; +// if ((p) && (p == magicfree)) +// { +// printf("CAUGHT!!!!! %p ...\n", p); +// abort(); +// } + free(p); + __free_hook = my_free_hook; +} +*/ + EAPI int e_precache_end = 0; /* local subsystem functions */