diff --git a/grid.c b/grid.c index 28680cbdd..da5c69177 100644 --- a/grid.c +++ b/grid.c @@ -74,11 +74,45 @@ grid_check_lines(struct grid *gd) } } } + +void +grid_check_is_clear(struct grid *gd) +{ + struct grid_line *gl; + u_int yy, ny; + + assert(gd != NULL); + + if (gd->sy == 0) { + assert(gd->linedata == NULL); + return; + } + + assert(gd->linedata != NULL); + + ny = gd->hsize + gd->sy; + for (yy = 0; yy < ny; yy++) { + gl = &gd->linedata[yy]; + + assert(gl->celldata == NULL); + assert(gl->cellused == 0); + assert(gl->cellsize == 0); + assert(gl->extddata == NULL); + assert(gl->extdsize == 0); + assert(gl->flags == 0); + assert(gl->time == 0); + } +} #else static void grid_check_lines(__unused struct grid *gd) { } + +void +grid_check_is_clear(__unused struct grid *gd) +{ +} #endif /* Store cell in entry. */ @@ -363,6 +397,7 @@ grid_create(u_int sx, u_int sy, u_int hlimit) else gd->linedata = NULL; + grid_check_is_clear(gd); return (gd); } diff --git a/screen.c b/screen.c index 8e513758e..f3fdfcbd4 100644 --- a/screen.c +++ b/screen.c @@ -123,7 +123,7 @@ screen_reinit(struct screen *s) s->saved_cy = UINT_MAX; screen_reset_tabs(s); - + grid_check_is_clear(s->grid); grid_clear_lines(s->grid, s->grid->hsize, s->grid->sy, 8); screen_clear_selection(s); diff --git a/tmux.h b/tmux.h index 863a41eca..175c9b78e 100644 --- a/tmux.h +++ b/tmux.h @@ -3323,6 +3323,7 @@ bitstr_t *fuzzy_match(const char *, const char *, u_int, u_int *); /* grid.c */ extern const struct grid_cell grid_default_cell; +void grid_check_is_clear(struct grid *); void grid_empty_line(struct grid *, u_int, u_int); void grid_set_tab(struct grid_cell *, u_int); int grid_cells_equal(const struct grid_cell *, const struct grid_cell *);