on master help sign in
Zero whole heap on initialisation
1980f49Edwin Brady
rts/idris_heap.c+2
@@ -110,12 +110,14 @@ void c_heap_destroy(CHeap * heap)
110void alloc_heap(Heap * h, size_t heap_size, size_t growth, char * old)
110void alloc_heap(Heap * h, size_t heap_size, size_t growth, char * old)
111{
111{
112 char * mem = malloc(heap_size);
112 char * mem = malloc(heap_size);
113+
113 if (mem == NULL) {
114 if (mem == NULL) {
114 fprintf(stderr,
115 fprintf(stderr,
115 "RTS ERROR: Unable to allocate heap. Requested %zd bytes.\n",
116 "RTS ERROR: Unable to allocate heap. Requested %zd bytes.\n",
116 heap_size);
117 heap_size);
117 exit(EXIT_FAILURE);
118 exit(EXIT_FAILURE);
118 }
119 }
120+ memset(mem, 0, heap_size);
119
121
120 h->heap = mem;
122 h->heap = mem;
121 h->next = aligned_heap_pointer(h->heap);
123 h->next = aligned_heap_pointer(h->heap);
rts/idris_rts.c−2
@@ -209,7 +209,6 @@ void * allocate(size_t sz, int lock) {
209}
209}
210
210
211void* iallocate(VM * vm, size_t isize, int outerlock) {
211void* iallocate(VM * vm, size_t isize, int outerlock) {
212−// return malloc(isize);
213 size_t size = aligned(isize);
212 size_t size = aligned(isize);
214
213
215#ifdef HAS_PTHREAD
214#ifdef HAS_PTHREAD
@@ -225,7 +224,6 @@ void* iallocate(VM * vm, size_t isize, int outerlock) {
225 char* ptr = vm->heap.next;
224 char* ptr = vm->heap.next;
226 vm->heap.next += size;
225 vm->heap.next += size;
227 assert(vm->heap.next <= vm->heap.end);
226 assert(vm->heap.next <= vm->heap.end);
228− memset(ptr, 0, size);
229 ((Hdr*)ptr)->sz = isize;
227 ((Hdr*)ptr)->sz = isize;
230
228
231#ifdef HAS_PTHREAD
229#ifdef HAS_PTHREAD