From e560bd2327f4d63d4bad1797d1d0e8b201e16067 Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Thu, 15 Jan 2009 17:54:45 -0800 Subject: [PATCH] added debugger hook --- lib/mem.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/mem.c b/lib/mem.c index b78a326..8e619dc 100644 --- a/lib/mem.c +++ b/lib/mem.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "mem.h" // memory allocation @@ -12,6 +13,11 @@ void rfx_free(void*ptr) free(ptr); } +void start_debugger() +{ + //*(int*)0=0; +} + void* rfx_alloc(int size) { void*ptr; @@ -24,7 +30,7 @@ void* rfx_alloc(int size) ptr = malloc(size); if(!ptr) { fprintf(stderr, "FATAL: Out of memory (while trying to claim %d bytes)\n", size); - /* TODO: we should send a signal, so that the debugger kicks in? */ + start_debugger(); exit(1); } return ptr; @@ -46,7 +52,7 @@ void* rfx_realloc(void*data, int size) if(!ptr) { fprintf(stderr, "FATAL: Out of memory (while trying to claim %d bytes)\n", size); - /* TODO: we should send a signal, so that the debugger kicks in? */ + start_debugger(); exit(1); } return ptr; @@ -66,7 +72,7 @@ void* rfx_calloc(int size) #endif if(!ptr) { fprintf(stderr, "FATAL: Out of memory (while trying to claim %d bytes)\n", size); - /* TODO: we should send a signal, so that the debugger kicks in? */ + start_debugger(); exit(1); } #ifndef HAVE_CALLOC -- 1.7.10.4