summaryrefslogtreecommitdiffstats
path: root/grid.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-08-21 21:10:37 +0000
committerTiago Cunha <tcunha@gmx.com>2009-08-21 21:10:37 +0000
commita004fc3592145bcefafb3044f2ab458a6f18f85c (patch)
tree7b4d3ce17189edb947870ac6786332865c39309c /grid.c
parent4b883524d8da98b2f00e83437cc06bd65228fc5b (diff)
Sync OpenBSD patchset 283:
Fix grid_expand_line so it actually works when the required size is bigger than 2 * the current size.
Diffstat (limited to 'grid.c')
-rw-r--r--grid.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/grid.c b/grid.c
index 23967871..3ffea84b 100644
--- a/grid.c
+++ b/grid.c
@@ -1,4 +1,4 @@
-/* $Id: grid.c,v 1.31 2009-08-21 21:09:13 tcunha Exp $ */
+/* $Id: grid.c,v 1.32 2009-08-21 21:10:37 tcunha Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -189,19 +189,22 @@ grid_scroll_line(struct grid *gd)
/* Expand line to fit to cell. */
void
-grid_expand_line(struct grid *gd, u_int py, u_int sx)
+grid_expand_line(struct grid *gd, u_int py, u_int wantx)
{
struct grid_line *gl;
- u_int xx;
+ u_int xx, sx;
gl = &gd->linedata[py];
- if (sx <= gl->cellsize)
+ if (wantx <= gl->cellsize)
return;
if (gl->cellsize > gd->sx / 2)
sx = gd->sx;
- else
- sx = 1 + gl->cellsize * 2;
+ else {
+ sx = gl->cellsize + 1;
+ while (sx < wantx)
+ sx *= 2;
+ }
gl->celldata = xrealloc(gl->celldata, sx, sizeof *gl->celldata);
for (xx = gl->cellsize; xx < sx; xx++)
grid_put_cell(gd, xx, py, &grid_default_cell);