# HG changeset patch # User Paul Boddie # Date 1483744864 -3600 # Node ID 45bc0b27d9b9f6a66f1d7e8bc3c8fe475edb11ff # Parent fa6f1d79ed59986df9e045201370b3895bc19911 Introduced libgc for memory allocation operations. diff -r fa6f1d79ed59 -r 45bc0b27d9b9 templates/Makefile --- a/templates/Makefile Fri Jan 06 23:34:37 2017 +0100 +++ b/templates/Makefile Sat Jan 07 00:21:04 2017 +0100 @@ -1,7 +1,7 @@ SRC = exceptions.c main.c $(wildcard native/*.c) ops.c progops.c progtypes.c $(wildcard src/*.c) OBJ = $(SRC:.c=.o) CFLAGS = -I. -finput-charset=UTF-8 -LDFLAGS = -lm +LDFLAGS = -lm -lgc all: main diff -r fa6f1d79ed59 -r 45bc0b27d9b9 templates/Makefile-debug --- a/templates/Makefile-debug Fri Jan 06 23:34:37 2017 +0100 +++ b/templates/Makefile-debug Sat Jan 07 00:21:04 2017 +0100 @@ -1,7 +1,7 @@ SRC = exceptions.c main.c $(wildcard native/*.c) ops.c progops.c progtypes.c $(wildcard src/*.c) OBJ = $(SRC:.c=.o) CFLAGS = -I. -finput-charset=UTF-8 -g -LDFLAGS = -lm +LDFLAGS = -lm -lgc all: main diff -r fa6f1d79ed59 -r 45bc0b27d9b9 templates/ops.c --- a/templates/ops.c Fri Jan 06 23:34:37 2017 +0100 +++ b/templates/ops.c Sat Jan 07 00:21:04 2017 +0100 @@ -16,7 +16,7 @@ this program. If not, see . */ -#include +#include "gc.h" /* GC_MALLOC, GC_REALLOC */ #include "ops.h" #include "progops.h" /* for raising errors */ #include "progconsts.h" @@ -303,7 +303,7 @@ void *__ALLOCATE(size_t nmemb, size_t size) { - void *ptr = calloc(nmemb, size); + void *ptr = GC_MALLOC(nmemb * size); /* sets memory to zero */ if (ptr == NULL) __raise_memory_error(); return ptr; @@ -311,7 +311,7 @@ void *__REALLOCATE(void *ptr, size_t size) { - void *nptr = realloc(ptr, size); + void *nptr = GC_REALLOC(ptr, size); if (nptr == NULL) __raise_memory_error(); return nptr;