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
This commit is contained in:
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.
* 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

View File

@ -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. */

View File

@ -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);

View File

@ -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);
}

View File

@ -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. */