aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornytpu <alex@nytpu.com>2021-05-31 14:46:06 -0600
committernytpu <alex@nytpu.com>2021-05-31 14:46:06 -0600
commitfce8e5643e57f7b5c6d5ba5a85525ea65cf59ca1 (patch)
tree3ff1e5eec98917145c5ea518a0b03270979f6571
parentadd delete_rows() function (diff)
downloaded-fce8e5643e57f7b5c6d5ba5a85525ea65cf59ca1.tar.bz2
ed-fce8e5643e57f7b5c6d5ba5a85525ea65cf59ca1.zip
add editor_deinit()
-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);
+}