summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/buffer.c b/buffer.c
index 8cf2760..308c12d 100644
--- a/buffer.c
+++ b/buffer.c
@@ -377,6 +377,7 @@ static void buffer_remove_last_edit_if_empty(TextBuffer *buffer) {
if (buffer->store_undo_events) {
BufferEdit *last_edit = arr_lastp(buffer->undo_history);
if (last_edit && !buffer_edit_does_anything(buffer, last_edit)) {
+ buffer_edit_free(last_edit);
arr_remove_last(buffer->undo_history);
}
}
@@ -435,7 +436,6 @@ static void buffer_line_free(Line *line) {
// Does not free the pointer `buffer` (buffer might not have even been allocated with malloc)
void buffer_free(TextBuffer *buffer) {
-
Line *lines = buffer->lines;
u32 nlines = buffer->nlines;
for (u32 i = 0; i < nlines; ++i) {
@@ -443,6 +443,11 @@ void buffer_free(TextBuffer *buffer) {
}
free(lines);
+ arr_foreach_ptr(buffer->undo_history, BufferEdit, edit)
+ buffer_edit_free(edit);
+ arr_foreach_ptr(buffer->redo_history, BufferEdit, edit)
+ buffer_edit_free(edit);
+
arr_free(buffer->undo_history);
arr_free(buffer->redo_history);