2016-02-18 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (do_replace_loop), src/text.c (do_int_spell_fix),
src/winio.c (edit_refresh): Fix Savannah bug #47127 the proper way.
+ * src/nano.c (free_filestruct): Allow the parameter to be NULL.
2016-02-16 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (initialize_buffer_text): Delete redundant assignment.
assert(openfile->current != NULL && openfile->current->data != NULL);
- /* If keep_cutbuffer is FALSE and the cutbuffer isn't empty, blow
- * away the text in the cutbuffer. */
- if (!keep_cutbuffer && cutbuffer != NULL) {
+ /* Empty the cutbuffer when a chain of cuts is broken. */
+ if (!keep_cutbuffer) {
free_filestruct(cutbuffer);
cutbuffer = NULL;
#ifdef DEBUG
return head;
}
-/* Free a filestruct. */
+/* Free a whole linked list of filestructs. */
void free_filestruct(filestruct *src)
{
- assert(src != NULL);
+ if (src == NULL)
+ return;
while (src->next != NULL) {
src = src->next;
*file_bot = openfile->filebot;
}
- openfile->fileage->next = NULL;
- free_filestruct(openfile->fileage);
+ delete_node(openfile->fileage);
/* Renumber starting with the line after the original
* file_bot. */
openfile->mark_set = FALSE;
openfile->mark_begin = NULL;
- if (cutbuffer != NULL)
- free_filestruct(cutbuffer);
+ free_filestruct(cutbuffer);
cutbuffer = oldcutbuffer;
cutbottom = oldcutbottom;
}
openfile->mark_set = TRUE;
goto_line_posx(u->lineno, u->begin);
cut_marked();
- if (u->cutbuffer != NULL)
- free_filestruct(u->cutbuffer);
+ free_filestruct(u->cutbuffer);
u->cutbuffer = cutbuffer;
u->cutbottom = cutbottom;
cutbuffer = oldcutbuffer;
while (dropit != NULL && dropit != thisitem) {
thefile->undotop = dropit->next;
free(dropit->strdata);
- if (dropit->cutbuffer != NULL)
- free_filestruct(dropit->cutbuffer);
+ free_filestruct(dropit->cutbuffer);
free(dropit);
dropit = thefile->undotop;
}
case CUT:
if (!cutbuffer)
break;
- if (u->cutbuffer)
- free_filestruct(u->cutbuffer);
+ free_filestruct(u->cutbuffer);
u->cutbuffer = copy_filestruct(cutbuffer);
if (u->mark_set) {
/* If the "marking" operation was from right-->left or