=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/grid.c,v retrieving revision 1.85 retrieving revision 1.86 diff -c -r1.85 -r1.86 *** src/usr.bin/tmux/grid.c 2018/07/11 06:43:45 1.85 --- src/usr.bin/tmux/grid.c 2018/07/11 06:51:39 1.86 *************** *** 1,4 **** ! /* $OpenBSD: grid.c,v 1.85 2018/07/11 06:43:45 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: grid.c,v 1.86 2018/07/11 06:51:39 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott *************** *** 286,291 **** --- 286,300 ---- return (0); } + /* Trim lines from the history. */ + static void + grid_trim_history(struct grid *gd, u_int ny) + { + grid_free_lines(gd, 0, ny); + memmove(&gd->linedata[0], &gd->linedata[ny], + (gd->hsize + gd->sy - ny) * (sizeof *gd->linedata)); + } + /* * Collect lines from the history if at the limit. Free the top (oldest) 10% * and shift up. *************** *** 308,316 **** * Free the lines from 0 to ny then move the remaining lines over * them. */ ! grid_free_lines(gd, 0, ny); ! memmove(&gd->linedata[0], &gd->linedata[ny], ! (gd->hsize + gd->sy - ny) * (sizeof *gd->linedata)); gd->hsize -= ny; if (gd->hscrolled > gd->hsize) --- 317,323 ---- * Free the lines from 0 to ny then move the remaining lines over * them. */ ! grid_trim_history(gd, ny); gd->hsize -= ny; if (gd->hscrolled > gd->hsize) *************** *** 340,348 **** void grid_clear_history(struct grid *gd) { ! grid_free_lines(gd, 0, gd->hsize); ! memmove(&gd->linedata[0], &gd->linedata[gd->hsize], ! gd->sy * (sizeof *gd->linedata)); gd->hscrolled = 0; gd->hsize = 0; --- 347,353 ---- void grid_clear_history(struct grid *gd) { ! grid_trim_history(gd, gd->hsize); gd->hscrolled = 0; gd->hsize = 0;