Commit 17f5c056 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey Committed by Benno Schulenberg
Browse files

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

These two functions unnecessarily copy make_new_node(); use that instead.
No related merge requests found
Showing with 2 additions and 12 deletions
+2 -12
...@@ -353,14 +353,10 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot, ...@@ -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. */ /* 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->fileage->data = mallocstrcpy(NULL, "");
openfile->filebot = openfile->fileage; openfile->filebot = openfile->fileage;
#ifndef DISABLE_COLOR
openfile->fileage->multidata = NULL;
#endif
/* Restore the current line and cursor position. If the mark begins /* Restore the current line and cursor position. If the mark begins
* inside the partition, set the beginning of the mark to where the * inside the partition, set the beginning of the mark to where the
* saved text used to start. */ * saved text used to start. */
......
...@@ -530,14 +530,8 @@ size_t strlenpt(const char *text) ...@@ -530,14 +530,8 @@ size_t strlenpt(const char *text)
/* Append a new magicline to filebot. */ /* Append a new magicline to filebot. */
void new_magicline(void) 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->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->filebot = openfile->filebot->next;
openfile->totsize++; openfile->totsize++;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment