diff options
Diffstat (limited to 'mem.c')
-rw-r--r-- | mem.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -3,12 +3,12 @@ #include <stdio.h> #include <stdlib.h> -void *M(void *p, size_t sz) { - if (sz == 0) { +void *M(void *p, size_t old, size_t new) { + if (new == 0) { free(p); return NULL; } else { - void *x = realloc(p, sz); + void *x = realloc(p, new); if (x == NULL) { printf("out of memory! aaaaaaa!!!!!\n"); exit(42); @@ -16,3 +16,9 @@ void *M(void *p, size_t sz) { return x; } } + +Obj *alloc_obj(size_t sz, ObjTy oty) { + Obj *o = M(NULL, 0, sz); + o->oty = oty; + return o; +} |