diff options
author | nicm <nicm> | 2015-09-25 15:53:07 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-09-25 15:53:07 +0000 |
commit | 28f23f18e9d79405a60348c4f7aeded33da9135b (patch) | |
tree | 0fbd5c6742b4cb4f46bd434d3ce291e486078bc5 /grid.c | |
parent | 2a62917444783e62ea5b8c13069aecb77b47ff07 (diff) | |
download | rtmux-28f23f18e9d79405a60348c4f7aeded33da9135b.tar.gz rtmux-28f23f18e9d79405a60348c4f7aeded33da9135b.tar.bz2 rtmux-28f23f18e9d79405a60348c4f7aeded33da9135b.zip |
Free the history when it is cleared, based on a diff from Carlo Cannas.
Diffstat (limited to 'grid.c')
-rw-r--r-- | grid.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -170,6 +170,18 @@ grid_scroll_history(struct grid *gd) gd->hsize++; } +/* Clear the history. */ +void +grid_clear_history(struct grid *gd) +{ + grid_clear_lines(gd, 0, gd->hsize); + grid_move_lines(gd, 0, gd->hsize, gd->sy); + + gd->hsize = 0; + gd->linedata = xreallocarray(gd->linedata, gd->sy, + sizeof *gd->linedata); +} + /* Scroll a region up, moving the top line into the history. */ void grid_scroll_history_region(struct grid *gd, u_int upper, u_int lower) @@ -344,8 +356,8 @@ grid_move_lines(struct grid *gd, u_int dy, u_int py, u_int ny) grid_clear_lines(gd, yy, 1); } - memmove( - &gd->linedata[dy], &gd->linedata[py], ny * (sizeof *gd->linedata)); + memmove(&gd->linedata[dy], &gd->linedata[py], + ny * (sizeof *gd->linedata)); /* Wipe any lines that have been moved (without freeing them). */ for (yy = py; yy < py + ny; yy++) { @@ -371,8 +383,8 @@ grid_move_cells(struct grid *gd, u_int dx, u_int px, u_int py, u_int nx) grid_expand_line(gd, py, px + nx); grid_expand_line(gd, py, dx + nx); - memmove( - &gl->celldata[dx], &gl->celldata[px], nx * sizeof *gl->celldata); + memmove(&gl->celldata[dx], &gl->celldata[px], + nx * sizeof *gl->celldata); /* Wipe any cells that have been moved. */ for (xx = px; xx < px + nx; xx++) { |