1 // malloc_hook, free_hook.
7 #include "cln/malloc.h"
14 #include "cln/exception.h"
17 extern "C" void* malloc (size_t size);
20 extern "C" void free (void* ptr);
25 // Just like malloc() but never return NULL pointers.
26 static void* xmalloc (size_t size)
28 void* ptr = malloc(size);
31 throw runtime_exception("Out of virtual memory.");
34 void* (*malloc_hook) (size_t size) = xmalloc;
35 void (*free_hook) (void* ptr) = free;