tweaks: merge two functions, as the first is called just once

This commit is contained in:
Benno Schulenberg 2019-06-01 11:10:48 +02:00
parent 2003413989
commit f63fee79e3
1 changed files with 19 additions and 22 deletions

View File

@ -642,31 +642,28 @@ void switch_to_next_buffer(void)
redecorate_after_switch();
}
/* Unlink a node from the rest of the circular list, and delete it. */
void unlink_opennode(openfilestruct *fileptr)
{
if (fileptr == startfile)
startfile = startfile->next;
fileptr->prev->next = fileptr->next;
fileptr->next->prev = fileptr->prev;
free(fileptr->filename);
free_lines(fileptr->filetop);
#ifndef NANO_TINY
free(fileptr->current_stat);
free(fileptr->lock_filename);
/* Free the undo stack. */
discard_until(NULL, fileptr, TRUE);
#endif
free(fileptr);
}
/* Remove the current buffer from the circular list of buffers. */
void close_buffer(void)
{
openfile = openfile->prev;
unlink_opennode(openfile->next);
openfilestruct *orphan = openfile;
if (orphan == startfile)
startfile = startfile->next;
orphan->prev->next = orphan->next;
orphan->next->prev = orphan->prev;
free(orphan->filename);
free_lines(orphan->filetop);
#ifndef NANO_TINY
free(orphan->current_stat);
free(orphan->lock_filename);
/* Free the undo stack. */
discard_until(NULL, orphan, TRUE);
#endif
openfile = orphan->prev;
free(orphan);
/* When just one buffer remains open, show "Exit" in the help lines. */
if (openfile == openfile->next)