blob: 225834dfdaa75dce142d8c2544a6be495ebb099e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "mem.h"
#include <stdio.h>
#include <stdlib.h>
void *M(State *S, void *p, size_t old, size_t new) {
if (new == 0) {
free(p);
return NULL;
} else {
void *x = realloc(p, new);
if (x == NULL) {
printf("out of memory! aaaaaaa!!!!!\n");
exit(42);
}
return x;
}
}
Obj *alloc_obj(State *S, size_t sz, ObjTy oty) {
Obj *o = M(S, NULL, 0, sz);
o->oty = oty;
return o;
}
|