diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2020-09-07 12:57:22 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2020-09-07 12:57:22 +0200 |
commit | efa55eb5b3d3a4942789bdf397c3a6d6226475d4 (patch) | |
tree | a3a3f3079bbff203ca6c70544b4258742f5f152d /src/lib/mpmalloc.cc | |
parent | 0558244645611f314f47e0fa427f7323ce253eaf (diff) |
Revert "remove external libraries from main branch"protocol-modeling
This reverts commit 0558244645611f314f47e0fa427f7323ce253eaf.
Diffstat (limited to 'src/lib/mpmalloc.cc')
-rw-r--r-- | src/lib/mpmalloc.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/lib/mpmalloc.cc b/src/lib/mpmalloc.cc new file mode 100644 index 0000000..2483a3a --- /dev/null +++ b/src/lib/mpmalloc.cc @@ -0,0 +1,42 @@ +#include <stdlib.h> +#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* mprealloc(void* addr, size_t size) +{ + void* ret = realloc(addr, size); +#ifdef ADDR_20BIT + kout << "realloc:" << addr << ":" << dec << (uint32_t)size << "@" << ret << endl; +#else + kout << "realloc:" << addr << ":" << dec << size << "@" << ret << endl; +#endif + return ret; +} + +void mpfree(void* addr) +{ + kout << "free:" << addr << endl; + free(addr); +} |