GC check allocation of new heap.
commitd6d07ff197b082bf4e25e6daaede73aa193a977e
authorCalvin Beck <hobbes@ualberta.ca>
dateSat 28 Feb 2015, 12:58 (12 years ago)
parent5475fe3
rts/idris_gc.c+8
@@ -119,6 +119,14 @@ void idris_gc(VM* vm) {
119119 char* newheap = malloc(vm->heap.size);
120120 char* oldheap = vm->heap.heap;
121121
122+ if (newheap == NULL) {
123+ fprintf(stderr,
124+ "GC ERROR: Unable to allocate new heap. Requested %zd bytes.\n",
125+ vm->heap.size);
126+
127+ exit(EXIT_FAILURE);
128+ }
129+
122130 vm->heap.heap = newheap;
123131#ifdef FORCE_ALIGNMENT
124132 if (((i_int)(vm->heap.heap)&1) == 1) {