From 72caa540202b01e5d012fd2d8a207452b5423d6c Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 22 Nov 2015 16:14:42 +0000 Subject: [PATCH] Deleting a node right after unlinking it. This now mirrors unlink_opennode() and delete_opennode(). git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5433 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 1 + src/nano.c | 6 ++++-- src/proto.h | 2 +- src/search.c | 2 -- src/text.c | 4 ---- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 760a463f..300d25f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ this function is only ever called with PASTE when cutbuffer != NULL. * src/text.c: Rewrap, rewrite, rename, and reorder some things. * src/text.c (do_undo, do_redo): Elide an unneeded variable. + * src/nano.c (unlink_node): After unlinking, also delete the node. 2015-11-21 Benno Schulenberg * src/nano.c (main): Let the value of a --fill option on the diff --git a/src/nano.c b/src/nano.c index 5e34c920..56a7c1ad 100644 --- a/src/nano.c +++ b/src/nano.c @@ -107,8 +107,8 @@ void splice_node(filestruct *begin, filestruct *newnode, filestruct end->prev = newnode; } -/* Unlink a node from the rest of the filestruct. */ -void unlink_node(const filestruct *fileptr) +/* Unlink a node from the rest of the filestruct and delete it. */ +void unlink_node(filestruct *fileptr) { assert(fileptr != NULL); @@ -116,6 +116,8 @@ void unlink_node(const filestruct *fileptr) fileptr->prev->next = fileptr->next; if (fileptr->next != NULL) fileptr->next->prev = fileptr->prev; + + delete_node(fileptr); } /* Delete a node from the filestruct. */ diff --git a/src/proto.h b/src/proto.h index e5b855e1..b6343cde 100644 --- a/src/proto.h +++ b/src/proto.h @@ -429,7 +429,7 @@ filestruct *make_new_node(filestruct *prevnode); filestruct *copy_node(const filestruct *src); void splice_node(filestruct *begin, filestruct *newnode, filestruct *end); -void unlink_node(const filestruct *fileptr); +void unlink_node(filestruct *fileptr); void delete_node(filestruct *fileptr); filestruct *copy_filestruct(const filestruct *src); void free_filestruct(filestruct *src); diff --git a/src/search.c b/src/search.c index 0562f985..202c9db4 100644 --- a/src/search.c +++ b/src/search.c @@ -1307,7 +1307,6 @@ void update_history(filestruct **h, const char *s) foo = p; bar = p->next; unlink_node(foo); - delete_node(foo); renumber(bar); } @@ -1319,7 +1318,6 @@ void update_history(filestruct **h, const char *s) *hage = (*hage)->next; unlink_node(foo); - delete_node(foo); renumber(*hage); } diff --git a/src/text.c b/src/text.c index f52071e7..a7d717a5 100644 --- a/src/text.c +++ b/src/text.c @@ -148,7 +148,6 @@ void do_deletion(undo_type action) openfile->filebot = openfile->current; unlink_node(foo); - delete_node(foo); renumber(openfile->current); openfile->totsize--; @@ -572,7 +571,6 @@ void do_undo(void) if (foo == openfile->filebot) openfile->filebot = f; unlink_node(foo); - delete_node(foo); } goto_line_posx(u->lineno, u->begin); break; @@ -707,7 +705,6 @@ void do_redo(void) if (tmp == openfile->filebot) openfile->filebot = f; unlink_node(tmp); - delete_node(tmp); } renumber(f); goto_line_posx(u->mark_begin_lineno, u->mark_begin_x); @@ -2099,7 +2096,6 @@ void do_justify(bool full_justify) #endif unlink_node(next_line); - delete_node(next_line); /* If we've removed the next line, we need to go through * this line again. */ -- 2.39.5