From 4b34d642384d6237c0af46fb48ec9e8bd98efad0 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Fri, 13 Sep 2019 13:51:11 -0400 Subject: Add free_list to free all nodes in linked list --- makefile | 4 ++-- node.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/makefile b/makefile index 27d0649..8c73a72 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ -CC = tcc -FLAGS = -g +CC = gcc +FLAGS = -g -O0 YACC = yacc LEX = lex diff --git a/node.c b/node.c index eaf4190..48826ca 100644 --- a/node.c +++ b/node.c @@ -54,8 +54,21 @@ node *n; for(tmp = n; tmp;) { n = tmp->next; + + free(tmp->name); + tmp->name = NULL; + + if (tmp->func_info) + free(tmp->func_info); + tmp->func_info = NULL; + + if (tmp->array_info) + free(tmp->array_info); + tmp->array_info = NULL; + free(tmp); tmp = NULL; + tmp = n; } } -- cgit v1.1