Freeing the cutbuffer after use.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5055 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2014-07-02 20:52:27 +00:00
parent 92213f9de8
commit 637b76b582
2 changed files with 17 additions and 1 deletions

View File

@ -1,8 +1,10 @@
2014-07-02 Mark Majeres <mark@engine12.com>
* src/text.c (undo_cut, redo_cut, update_undo): Handle the
cases of cutting-from-cursor-to-end-of-line properly.
cases of cutting-from-cursor-to-end-of-line correctly.
* src/nano.c (do_input): Don't preserve the cutbuffer when
CUT_TO_END is toggled -- it would intermix two cut types.
* src/text.c (redo_cut, do_undo, do_redo): Don't forget to
free the cutbuffer after use.
2014-07-02 Benno Schulenberg <bensberg@justemail.net>
* src/proto.h: Add a typedef for a pointer to a function.

View File

@ -399,6 +399,10 @@ void redo_cut(undo *u)
if (!u->cutbuffer)
return;
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
cutbuffer = NULL;
cutbottom = NULL;
goto_line_posx(u->lineno, u->begin);
if (ISSET(NO_NEWLINES) && openfile->current->lineno != u->lineno) {
@ -416,6 +420,11 @@ void redo_cut(undo *u)
openfile->mark_begin = NULL;
openfile->mark_begin_x = 0;
edit_refresh_needed = TRUE;
if (cutbuffer != NULL)
free_filestruct(cutbuffer);
cutbuffer = oldcutbuffer;
cutbottom = oldcutbottom;
}
/* Undo the last thing(s) we did. */
@ -525,6 +534,8 @@ void do_undo(void)
openfile->mark_set = TRUE;
goto_line_posx(u->lineno, u->begin);
cut_marked();
if (u->cutbuffer != NULL)
free_filestruct(u->cutbuffer);
u->cutbuffer = cutbuffer;
u->cutbottom = cutbottom;
cutbuffer = oldcutbuffer;
@ -656,6 +667,8 @@ void do_redo(void)
redidmsg = _("text insert");
goto_line_posx(u->lineno, u->begin);
copy_from_filestruct(u->cutbuffer);
free_filestruct(u->cutbuffer);
u->cutbuffer = NULL;
break;
default:
redidmsg = _("Internal error: unknown type. Please save your work.");
@ -924,6 +937,7 @@ void add_undo(undo_type current_action)
break;
#endif /* !DISABLE_WRAPPING */
case INSERT:
break;
case REPLACE:
data = mallocstrcpy(NULL, fs->current->data);
u->strdata = data;