summaryrefslogtreecommitdiff
path: root/mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'mem.c')
-rw-r--r--mem.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/mem.c b/mem.c
index 6e0bc1b..d464f7d 100644
--- a/mem.c
+++ b/mem.c
@@ -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;
+}