From 28e7dd47d568908702264977d70860c25467fb6e Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Thu, 8 Jul 2021 17:07:15 +0000 Subject: Add a mark-sweep garbage collector --- builtins.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'builtins.c') diff --git a/builtins.c b/builtins.c index bebf0d1..56576a8 100644 --- a/builtins.c +++ b/builtins.c @@ -8,7 +8,7 @@ #define BuiltinProto(name) int name(Term *, Binding **, Module *) #define Match(X, Y) (runestrcmp(name, X) == 0 && arity == Y) #define Throw(What) do{\ - Goal *g = malloc(sizeof(Goal)); \ + Goal *g = gmalloc(sizeof(Goal)); \ g->goal = What; \ g->module = usermodule; \ g->catcher = nil; \ @@ -504,14 +504,14 @@ builtincatch(Term *goal, Binding **bindings, Module *module) Term *catcher = catchgoal->next; Term *recover = catcher->next; - Goal *catchframe = malloc(sizeof(Goal)); + Goal *catchframe = gmalloc(sizeof(Goal)); catchframe->goal = recover; catchframe->module = module; catchframe->catcher = catcher; catchframe->next = goalstack; goalstack = catchframe; - Goal *g = malloc(sizeof(Goal)); + Goal *g = gmalloc(sizeof(Goal)); g->goal = catchgoal; g->module = module; g->catcher = nil; @@ -543,7 +543,7 @@ builtinthrow(Term *goal, Binding **bindings, Module *module) return 0; }else{ goalstack = g->next; - Goal *newgoal = malloc(sizeof(Goal)); + Goal *newgoal = gmalloc(sizeof(Goal)); newgoal->goal = copyterm(g->goal, nil); newgoal->module = module; newgoal->catcher = nil; -- cgit v1.2.3