diff --git a/ChangeLog b/ChangeLog index 760a463ffe1fcf35da40e7e03bbf441dedc67faa..300d25f4add5b3d0b40e4f2cf7043100dc73ac6b 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 <bensberg@justemail.net> * src/nano.c (main): Let the value of a --fill option on the diff --git a/src/nano.c b/src/nano.c index 5e34c92018f80f35dc31f390159f29a3de66d385..56a7c1ada09686e1960606ea9ebed2ff5de2659c 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 e5b855e1bd0924c7814ff3a84b66d07169788f96..b6343cdeb6bf96e0c5280c2a9043e450841e7843 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 0562f98589238071d74fa44fa272d432fd4298e4..202c9db46e4fc5cf393da5856511509a3d1e7127 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 f52071e7f21fa61ce4687936dbaf856bbdf44507..a7d717a53ac11c9bedbe774bd35dcf3ffe02e2ed 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. */