tweaks: reduce duplicate code in new_magicline() and move_to_filestruct()

These two functions unnecessarily copy make_new_node(); use that instead.
master
David Lawrence Ramsey 2017-02-09 16:00:07 -06:00 committed by Benno Schulenberg
parent 914af36546
commit 17f5c056ca
2 changed files with 2 additions and 12 deletions

View File

@ -353,14 +353,10 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
}
/* Since the text has now been saved, remove it from the filestruct. */
openfile->fileage = (filestruct *)nmalloc(sizeof(filestruct));
openfile->fileage = make_new_node(NULL);
openfile->fileage->data = mallocstrcpy(NULL, "");
openfile->filebot = openfile->fileage;
#ifndef DISABLE_COLOR
openfile->fileage->multidata = NULL;
#endif
/* Restore the current line and cursor position. If the mark begins
* inside the partition, set the beginning of the mark to where the
* saved text used to start. */

View File

@ -530,14 +530,8 @@ size_t strlenpt(const char *text)
/* Append a new magicline to filebot. */
void new_magicline(void)
{
openfile->filebot->next = (filestruct *)nmalloc(sizeof(filestruct));
openfile->filebot->next = make_new_node(openfile->filebot);
openfile->filebot->next->data = mallocstrcpy(NULL, "");
openfile->filebot->next->prev = openfile->filebot;
openfile->filebot->next->next = NULL;
openfile->filebot->next->lineno = openfile->filebot->lineno + 1;
#ifndef DISABLE_COLOR
openfile->filebot->next->multidata = NULL;
#endif
openfile->filebot = openfile->filebot->next;
openfile->totsize++;
}