From: Michael D. Lowis Date: Fri, 1 Jan 2016 16:21:55 +0000 (-0500) Subject: Added code to gracefully cleanup and shutdown X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=1486a1174f39409a366e69e174d6fee0dd7b67d7;p=projs%2Ftide.git Added code to gracefully cleanup and shutdown --- 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