aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common.h1
-rw-r--r--main.c9
2 files changed, 10 insertions, 0 deletions
diff --git a/common.h b/common.h
index 535ae6b..01a5f11 100644
--- a/common.h
+++ b/common.h
@@ -61,5 +61,6 @@ void die(const char *m);
// initialize global struct Buffer to null/zero values
void editor_init(void);
+void editor_deinit(void);
#endif // _COMMON_H
diff --git a/main.c b/main.c
index 3c919a2..8a696a8 100644
--- a/main.c
+++ b/main.c
@@ -99,6 +99,7 @@ main(int argc, char *argv[])
err = print_rows(0, B.numrows);
if (err < 0) die("print_rows");
+ editor_deinit();
return EXIT_SUCCESS;
}
@@ -120,3 +121,11 @@ editor_init(void)
B.rows = NULL;
B.last_err = "";
}
+
+void
+editor_deinit(void)
+{
+ for (int i = 0; i < B.numrows; ++i) { free(B.rows[i].chars); }
+ free(B.rows);
+ free(B.filename);
+}