Index: src/files.c =================================================================== --- src/files.c (revision 5649) +++ src/files.c (working copy) @@ -75,11 +75,11 @@ * move to it. */ if (openfile == NULL) { openfile = make_new_opennode(); - splice_opennode(openfile, openfile, openfile); + splice_opennode(openfile, openfile); /* Otherwise, make a new entry for openfile, splice it in after * the current entry, and move to it. */ } else { - splice_opennode(openfile, make_new_opennode(), openfile->next); + splice_opennode(openfile, make_new_opennode()); openfile = openfile->next; /* More than one file open, show Close in help lines. */ exitfunc->desc = close_tag; Index: src/nano.c =================================================================== --- src/nano.c (revision 5649) +++ src/nano.c (working copy) @@ -525,18 +525,16 @@ return (openfilestruct *)nmalloc(sizeof(openfilestruct)); } -/* Splice a node into an existing openfilestruct. */ -void splice_opennode(openfilestruct *begin, openfilestruct *newnode, - openfilestruct *end) +/* Splice a node into an existing linked list of openfilestructs. */ +void splice_opennode(openfilestruct *afterthis, openfilestruct *newnode) { - assert(newnode != NULL && begin != NULL); + assert(newnode != NULL && afterthis != NULL); - newnode->next = end; - newnode->prev = begin; - begin->next = newnode; - - if (end != NULL) - end->prev = newnode; + newnode->next = afterthis->next; + newnode->prev = afterthis; + if (afterthis->next != NULL) + afterthis->next->prev = newnode; + afterthis->next = newnode; } /* Unlink a node from the rest of the openfilestruct, and delete it. */ Index: src/proto.h =================================================================== --- src/proto.h (revision 5649) +++ src/proto.h (working copy) @@ -447,8 +447,7 @@ 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 splice_opennode(openfilestruct *afterthis, openfilestruct *newnode); void unlink_opennode(openfilestruct *fileptr); void delete_opennode(openfilestruct *fileptr); #ifdef DEBUG