From c055e629c75fe3acade3f86abd9a90c12d8ee43a Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 28 Feb 2020 19:24:31 +0100 Subject: [PATCH] tweaks: copy and store a deleted character in a conciser manner --- src/text.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/text.c b/src/text.c index 67819dba..f866c698 100644 --- a/src/text.c +++ b/src/text.c @@ -1145,11 +1145,10 @@ void add_undo(undo_type action, const char *message) /* When not at the end of a line, store the deleted character; * otherwise, morph the undo item into a line join. */ if (openfile->current->data[openfile->current_x] != '\0') { - char *char_buf = charalloc(MAXCHARLEN + 1); - int charlen = collect_char(&openfile->current->data[u->head_x], - char_buf); - char_buf[charlen] = '\0'; - u->strdata = char_buf; + int charlen = char_length(openfile->current->data + u->head_x); + + u->strdata = measured_copy(openfile->current->data + u->head_x, + charlen); if (u->type == BACK) u->tail_x += charlen; break;