Eliding splice_opennode() by handling the two cases (the creation of
the first element, and the insertion of a new element) directly. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5678 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
3b8989b0a9
commit
486e828443
|
@ -2,6 +2,9 @@
|
|||
* src/browser.c (do_browser): Plug a memory leak by not copying
|
||||
a string twice. This fixes Savannah bug #47206.
|
||||
* src/browser.c (do_browser): Now put things in the proper order.
|
||||
* src/files.c (make_new_buffer), src/nano.c (splice_opennode): Elide
|
||||
the latter function, by handling the two cases (the creation of the
|
||||
first element, and the insertion of a new element) directly.
|
||||
|
||||
2016-02-23 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/prompt.c (do_statusbar_output, do_statusbar_delete):
|
||||
|
|
24
src/files.c
24
src/files.c
|
@ -71,17 +71,25 @@ bool has_valid_path(const char *filename)
|
|||
* called from open_buffer(). */
|
||||
void make_new_buffer(void)
|
||||
{
|
||||
/* If there are no entries in openfile, make the first one and
|
||||
* move to it. */
|
||||
if (openfile == NULL) {
|
||||
openfile = make_new_opennode();
|
||||
splice_opennode(openfile, openfile, openfile);
|
||||
/* Otherwise, make a new entry for openfile, splice it in after
|
||||
* the current entry, and move to it. */
|
||||
|
||||
/* Make the first open file the only element in a circular list. */
|
||||
openfile->prev = openfile;
|
||||
openfile->next = openfile;
|
||||
} else {
|
||||
splice_opennode(openfile, make_new_opennode(), openfile->next);
|
||||
openfile = openfile->next;
|
||||
/* More than one file open, show Close in help lines. */
|
||||
openfilestruct *newnode = make_new_opennode();
|
||||
|
||||
/* Add the new open file after the current one in the list. */
|
||||
newnode->prev = openfile;
|
||||
newnode->next = openfile->next;
|
||||
openfile->next->prev = newnode;
|
||||
openfile->next = newnode;
|
||||
|
||||
/* Make the new file the current one. */
|
||||
openfile = newnode;
|
||||
|
||||
/* There is more than one file open: show Close in help lines. */
|
||||
exitfunc->desc = close_tag;
|
||||
}
|
||||
|
||||
|
|
14
src/nano.c
14
src/nano.c
|
@ -525,20 +525,6 @@ openfilestruct *make_new_opennode(void)
|
|||
return (openfilestruct *)nmalloc(sizeof(openfilestruct));
|
||||
}
|
||||
|
||||
/* Splice a node into an existing openfilestruct. */
|
||||
void splice_opennode(openfilestruct *begin, openfilestruct *newnode,
|
||||
openfilestruct *end)
|
||||
{
|
||||
assert(newnode != NULL && begin != NULL);
|
||||
|
||||
newnode->next = end;
|
||||
newnode->prev = begin;
|
||||
begin->next = newnode;
|
||||
|
||||
if (end != NULL)
|
||||
end->prev = newnode;
|
||||
}
|
||||
|
||||
/* Unlink a node from the rest of the openfilestruct, and delete it. */
|
||||
void unlink_opennode(openfilestruct *fileptr)
|
||||
{
|
||||
|
|
|
@ -447,8 +447,6 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
|
|||
filestruct *top, size_t top_x, filestruct *bot, size_t bot_x);
|
||||
void copy_from_filestruct(filestruct *somebuffer);
|
||||
openfilestruct *make_new_opennode(void);
|
||||
void splice_opennode(openfilestruct *begin, openfilestruct *newnode,
|
||||
openfilestruct *end);
|
||||
void unlink_opennode(openfilestruct *fileptr);
|
||||
void delete_opennode(openfilestruct *fileptr);
|
||||
void print_view_warning(void);
|
||||
|
|
Loading…
Reference in New Issue