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
|
* src/browser.c (do_browser): Plug a memory leak by not copying
|
||||||
a string twice. This fixes Savannah bug #47206.
|
a string twice. This fixes Savannah bug #47206.
|
||||||
* src/browser.c (do_browser): Now put things in the proper order.
|
* 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>
|
2016-02-23 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/prompt.c (do_statusbar_output, do_statusbar_delete):
|
* 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(). */
|
* called from open_buffer(). */
|
||||||
void make_new_buffer(void)
|
void make_new_buffer(void)
|
||||||
{
|
{
|
||||||
/* If there are no entries in openfile, make the first one and
|
|
||||||
* move to it. */
|
|
||||||
if (openfile == NULL) {
|
if (openfile == NULL) {
|
||||||
openfile = make_new_opennode();
|
openfile = make_new_opennode();
|
||||||
splice_opennode(openfile, openfile, openfile);
|
|
||||||
/* Otherwise, make a new entry for openfile, splice it in after
|
/* Make the first open file the only element in a circular list. */
|
||||||
* the current entry, and move to it. */
|
openfile->prev = openfile;
|
||||||
|
openfile->next = openfile;
|
||||||
} else {
|
} else {
|
||||||
splice_opennode(openfile, make_new_opennode(), openfile->next);
|
openfilestruct *newnode = make_new_opennode();
|
||||||
openfile = openfile->next;
|
|
||||||
/* More than one file open, show Close in help lines. */
|
/* 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;
|
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));
|
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. */
|
/* Unlink a node from the rest of the openfilestruct, and delete it. */
|
||||||
void unlink_opennode(openfilestruct *fileptr)
|
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);
|
filestruct *top, size_t top_x, filestruct *bot, size_t bot_x);
|
||||||
void copy_from_filestruct(filestruct *somebuffer);
|
void copy_from_filestruct(filestruct *somebuffer);
|
||||||
openfilestruct *make_new_opennode(void);
|
openfilestruct *make_new_opennode(void);
|
||||||
void splice_opennode(openfilestruct *begin, openfilestruct *newnode,
|
|
||||||
openfilestruct *end);
|
|
||||||
void unlink_opennode(openfilestruct *fileptr);
|
void unlink_opennode(openfilestruct *fileptr);
|
||||||
void delete_opennode(openfilestruct *fileptr);
|
void delete_opennode(openfilestruct *fileptr);
|
||||||
void print_view_warning(void);
|
void print_view_warning(void);
|
||||||
|
|
Loading…
Reference in New Issue