summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/grid.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-09-25 15:53:08 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-09-25 15:53:08 +0000
commit539c02cea5cb585e2e14e5e29c0c7b1a27bcbde6 (patch)
tree5e8a23e65cb7de1a45467126d0d7cee3928c49ae /usr.bin/tmux/grid.c
parent6558b9c54e4e8a195185488f7f842d226c53092d (diff)
Free the history when it is cleared, based on a diff from Carlo Cannas.
Diffstat (limited to 'usr.bin/tmux/grid.c')
-rw-r--r--usr.bin/tmux/grid.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c
index a3015f460e2..36ee9d23a75 100644
--- a/usr.bin/tmux/grid.c
+++ b/usr.bin/tmux/grid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grid.c,v 1.45 2015/09/02 17:12:07 nicm Exp $ */
+/* $OpenBSD: grid.c,v 1.46 2015/09/25 15:53:07 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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++) {