X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fmem.c;h=6dd58f59ccb4f091c10c9e2666954888fe5e1000;hp=98f4b1dcd397addec19087c7c96e81b8e96f31f2;hb=6595b27601ff72318acbcec25861ba1c824777df;hpb=03b598c965020825e9ffa88a8d32b8c1170f2419 diff --git a/lib/mem.c b/lib/mem.c index 98f4b1d..6dd58f5 100644 --- a/lib/mem.c +++ b/lib/mem.c @@ -1,6 +1,8 @@ #include #include #include +#include +#include "mem.h" // memory allocation @@ -11,6 +13,11 @@ void rfx_free(void*ptr) free(ptr); } +void start_debugger() +{ + //*(int*)0=0; +} + void* rfx_alloc(int size) { void*ptr; @@ -23,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; @@ -45,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; @@ -59,13 +66,13 @@ void* rfx_calloc(int size) return 0; } #ifdef HAVE_CALLOC - ptr = calloc(size); + ptr = calloc(1, size); #else ptr = malloc(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 @@ -73,6 +80,12 @@ void* rfx_calloc(int size) #endif return ptr; } +#ifndef HAVE_CALLOC +void* rfx_calloc_replacement(int nmemb, int size) +{ + rfx_calloc(nmemb*size); +} +#endif #ifdef MEMORY_INFO long rfx_memory_used()