From 82a7c12e8338288ccb40d213fcc9e15d102aa968 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Thu, 1 Aug 2019 16:42:36 +0100 Subject: remove trailing blank lines in write_file - change check_bound --- lineset.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lineset.c') diff --git a/lineset.c b/lineset.c index 0d810b8..349504c 100644 --- a/lineset.c +++ b/lineset.c @@ -144,13 +144,18 @@ void copy_lines_to_ring(int y1, int y2, int which){ else idx = undo_cur + 1; if (idx >= undo_sz - 1){ - undo_sz += 10; - tmp = realloc(undo, undo_sz * sizeof(lineset_t)); + tmp = realloc(undo, (undo_sz + 10) * sizeof(lineset_t)); if (tmp == NULL){ fprintf(stderr, "Error allocating undo buffer"); exit(1); } undo = tmp; + for (i=0; i<10; i++){ + undo[undo_sz + i].sz = 0; + undo[undo_sz + i].l = NULL; + undo[undo_sz + i].num = 0; + } + undo_sz += 10; } ensure_num_lines(&(undo[idx]), y2 - y1 + 1); for(i=y1; i<=y2; i++){ -- cgit v1.2.3