git » unicorn-sparkle-basic.git » commit 2c4fb8f

use GC_malloc for ast nodes

author Alan Dipert
2024-04-14 04:28:26 UTC
committer Alan Dipert
2024-04-14 04:28:26 UTC
parent ca024196405587dfbd521d4fd79545fb74559c63

use GC_malloc for ast nodes

parse.c +2 -5

diff --git a/parse.c b/parse.c
index d161747..676b2ed 100644
--- a/parse.c
+++ b/parse.c
@@ -6,16 +6,13 @@
  */
 
 #include "parse.h"
+#include <gc.h>
 #include <stdio.h>
 
 struct node_tag *ast_last_numbered_line;
 
 static struct node_tag *ast_alloc(enum NODE_TYPE node_type) {
-  struct node_tag *new_node = malloc(sizeof(struct node_tag));
-  if (new_node == NULL) {
-    fprintf(stderr, "Memory allocation failed at %s:%d\n", __FILE__, __LINE__);
-    exit(EXIT_FAILURE);
-  }
+  struct node_tag *new_node = GC_malloc(sizeof(struct node_tag));
   new_node->type = node_type;
   return new_node;
 }