From 1486a1174f39409a366e69e174d6fee0dd7b67d7 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Fri, 1 Jan 2016 11:21:55 -0500 Subject: [PATCH] Added code to gracefully cleanup and shutdown --- source/main.c | 8 ++++++++ source/util.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/source/main.c b/source/main.c index 96d79b4..2184c8b 100644 --- a/source/main.c +++ b/source/main.c @@ -36,6 +36,13 @@ static void setup(void) static void cleanup(void) { + Line* line = Curr_File.first; + while (line) { + Line* deadite = line; + line = line->next; + free(deadite->text); + free(deadite); + } } static void load(char* fname) @@ -53,6 +60,7 @@ static void load(char* fname) Curr_File.last = line; } } + fclose(file); } static void edit(void) diff --git a/source/util.h b/source/util.h index 7c5ea5d..49f81c9 100644 --- a/source/util.h +++ b/source/util.h @@ -102,4 +102,12 @@ static char* efreadline(FILE* input) return str; } +/* String Handling */ +char* estrdup(const char *s) +{ + char* ns = (char*)emalloc(strlen(s) + 1); + strcpy(ns,s); + return ns; +} + #endif -- 2.54.0