diff options
Diffstat (limited to 'lineset.c')
-rw-r--r-- | lineset.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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++){ |