From ebd3e2890cad3fbc9b0293b91173995d191ee804 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 13 Dec 2018 14:24:13 +0100 Subject: mpmalloc --- src/lib/mpmalloc.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/lib/mpmalloc.cc (limited to 'src/lib') diff --git a/src/lib/mpmalloc.cc b/src/lib/mpmalloc.cc new file mode 100644 index 0000000..db4a87a --- /dev/null +++ b/src/lib/mpmalloc.cc @@ -0,0 +1,28 @@ +#include +#include "driver/stdout.h" +#include "lib/mpmalloc.h" + +void* mpcalloc(size_t nmemb, size_t size) { + void* ret = calloc(nmemb, size); +#ifdef ADDR_20BIT + kout << "calloc:" << dec << (uint32_t)nmemb << "x" << (uint32_t)size << "@" << ret << endl; +#else + kout << "calloc:" << dec << nmemb << "x" << size << "@" << ret << endl; +#endif + return ret; +} + +void* mpmalloc(size_t size) { + void* ret = malloc(size); +#ifdef ADDR_20BIT + kout << "malloc:" << dec << (uint32_t)size << "@" << ret << endl; +#else + kout << "malloc:" << dec << size << "@" << ret << endl; +#endif + return ret; +} + +void mpfree(void* addr) { + kout << "free:" << addr << endl; + free(addr); +} -- cgit v1.2.3