#include #include #include "memory.h" #include "exception.h" static void * (*malloc_fun)(size_t) = malloc; static void (*free_fun)(void *) = free; DEFINE_EXCEPTION(memory_default); void *memory_alloc(size_t size) { void *p = malloc_fun(size); if (p == NULL) RAISE(memory_default); return p; } void memory_free(void *p) { free_fun(p); } void memory_set_functions(void *(*malloc_user_fun)(size_t), void (*free_user_fun)(void*)) { malloc_fun = malloc_user_fun; free_fun = free_user_fun; }