1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include "mem.h" #include <stdio.h> #include <stdlib.h> 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; } }