]> git.mdlowis.com Git - projs/tide.git/commitdiff
Added code to gracefully cleanup and shutdown
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 1 Jan 2016 16:21:55 +0000 (11:21 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 1 Jan 2016 16:21:55 +0000 (11:21 -0500)
source/main.c
source/util.h

index 96d79b4921ef37fd148ebee08b7d849e7d63b853..2184c8bfefb3846493b2a8a7532b54bb33728c7a 100644 (file)
@@ -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)
index 7c5ea5d48d3c0296a1d955379ff27b0dabdd36b2..49f81c94d925d9714b95b2b853108d9045d10afd 100644 (file)
@@ -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