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
master
Benno Schulenberg 2015-11-22 16:14:42 +00:00
parent 81f3177a33
commit 72caa54020
5 changed files with 6 additions and 9 deletions

View File

@ -3,6 +3,7 @@
this function is only ever called with PASTE when cutbuffer != NULL. this function is only ever called with PASTE when cutbuffer != NULL.
* src/text.c: Rewrap, rewrite, rename, and reorder some things. * src/text.c: Rewrap, rewrite, rename, and reorder some things.
* src/text.c (do_undo, do_redo): Elide an unneeded variable. * 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> 2015-11-21 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (main): Let the value of a --fill option on the * src/nano.c (main): Let the value of a --fill option on the

View File

@ -107,8 +107,8 @@ void splice_node(filestruct *begin, filestruct *newnode, filestruct
end->prev = newnode; end->prev = newnode;
} }
/* Unlink a node from the rest of the filestruct. */ /* Unlink a node from the rest of the filestruct and delete it. */
void unlink_node(const filestruct *fileptr) void unlink_node(filestruct *fileptr)
{ {
assert(fileptr != NULL); assert(fileptr != NULL);
@ -116,6 +116,8 @@ void unlink_node(const filestruct *fileptr)
fileptr->prev->next = fileptr->next; fileptr->prev->next = fileptr->next;
if (fileptr->next != NULL) if (fileptr->next != NULL)
fileptr->next->prev = fileptr->prev; fileptr->next->prev = fileptr->prev;
delete_node(fileptr);
} }
/* Delete a node from the filestruct. */ /* Delete a node from the filestruct. */

View File

@ -429,7 +429,7 @@ filestruct *make_new_node(filestruct *prevnode);
filestruct *copy_node(const filestruct *src); filestruct *copy_node(const filestruct *src);
void splice_node(filestruct *begin, filestruct *newnode, filestruct void splice_node(filestruct *begin, filestruct *newnode, filestruct
*end); *end);
void unlink_node(const filestruct *fileptr); void unlink_node(filestruct *fileptr);
void delete_node(filestruct *fileptr); void delete_node(filestruct *fileptr);
filestruct *copy_filestruct(const filestruct *src); filestruct *copy_filestruct(const filestruct *src);
void free_filestruct(filestruct *src); void free_filestruct(filestruct *src);

View File

@ -1307,7 +1307,6 @@ void update_history(filestruct **h, const char *s)
foo = p; foo = p;
bar = p->next; bar = p->next;
unlink_node(foo); unlink_node(foo);
delete_node(foo);
renumber(bar); renumber(bar);
} }
@ -1319,7 +1318,6 @@ void update_history(filestruct **h, const char *s)
*hage = (*hage)->next; *hage = (*hage)->next;
unlink_node(foo); unlink_node(foo);
delete_node(foo);
renumber(*hage); renumber(*hage);
} }

View File

@ -148,7 +148,6 @@ void do_deletion(undo_type action)
openfile->filebot = openfile->current; openfile->filebot = openfile->current;
unlink_node(foo); unlink_node(foo);
delete_node(foo);
renumber(openfile->current); renumber(openfile->current);
openfile->totsize--; openfile->totsize--;
@ -572,7 +571,6 @@ void do_undo(void)
if (foo == openfile->filebot) if (foo == openfile->filebot)
openfile->filebot = f; openfile->filebot = f;
unlink_node(foo); unlink_node(foo);
delete_node(foo);
} }
goto_line_posx(u->lineno, u->begin); goto_line_posx(u->lineno, u->begin);
break; break;
@ -707,7 +705,6 @@ void do_redo(void)
if (tmp == openfile->filebot) if (tmp == openfile->filebot)
openfile->filebot = f; openfile->filebot = f;
unlink_node(tmp); unlink_node(tmp);
delete_node(tmp);
} }
renumber(f); renumber(f);
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x); goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
@ -2099,7 +2096,6 @@ void do_justify(bool full_justify)
#endif #endif
unlink_node(next_line); unlink_node(next_line);
delete_node(next_line);
/* If we've removed the next line, we need to go through /* If we've removed the next line, we need to go through
* this line again. */ * this line again. */