#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
+#include "mem.h"
// memory allocation
free(ptr);
}
+void start_debugger()
+{
+ //*(int*)0=0;
+}
+
void* rfx_alloc(int size)
{
void*ptr;
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;
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;
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
#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()