From f67a3fd05c1b2fe8c749fc2f58287b1b14b011d8 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 4 Aug 2023 22:38:48 +0100 Subject: move M to its own file --- mem.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 mem.c (limited to 'mem.c') diff --git a/mem.c b/mem.c new file mode 100644 index 0000000..6e0bc1b --- /dev/null +++ b/mem.c @@ -0,0 +1,18 @@ +#include "mem.h" + +#include +#include + +void *M(void *p, size_t sz) { + if (sz == 0) { + free(p); + return NULL; + } else { + void *x = realloc(p, sz); + if (x == NULL) { + printf("out of memory! aaaaaaa!!!!!\n"); + exit(42); + } + return x; + } +} -- cgit v1.2.3