Skip to content

Commit c2af59a

Browse files
author
tcunha
committed
Sync OpenBSD patchset 226:
Change the way the grid is stored, previously it was: - a two-dimensional array of cells; - a two-dimensional array of utf8 data; - an array of line lengths. Now it is a single array of a new struct grid_line each of which represents a line and contains the length and an array of cells and an array of utf8 data. This will make it easier to add additional per-line members, such as flags.
1 parent 3f92b95 commit c2af59a

7 files changed

+117
-129
lines changed

cmd-list-windows.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Id: cmd-list-windows.c,v 1.39 2009-08-08 16:03:09 nicm Exp $ */
1+
/* $Id: cmd-list-windows.c,v 1.40 2009-08-09 17:28:23 tcunha Exp $ */
22

33
/*
44
* Copyright (c) 2007 Nicholas Marriott <[email protected]>
@@ -48,6 +48,7 @@ cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
4848
struct window *w;
4949
struct window_pane *wp;
5050
struct grid *gd;
51+
struct grid_line *gl;
5152
u_int i;
5253
unsigned long long size;
5354
const char *name;
@@ -65,11 +66,11 @@ cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
6566

6667
size = 0;
6768
for (i = 0; i < gd->hsize; i++) {
68-
size += gd->size[i] * sizeof **gd->data;
69-
size += gd->usize[i] * sizeof **gd->udata;
69+
gl = &gd->linedata[i];
70+
size += gl->cellsize * sizeof *gl->celldata;
71+
size += gl->utf8size * sizeof *gl->utf8data;
7072
}
71-
size += gd->hsize * (sizeof *gd->data);
72-
size += gd->hsize * (sizeof *gd->size);
73+
size += gd->hsize * sizeof *gd->linedata;
7374

7475
name = NULL;
7576
if (wp->fd != -1)

cmd-server-info.c

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Id: cmd-server-info.c,v 1.23 2009-07-28 23:04:29 tcunha Exp $ */
1+
/* $Id: cmd-server-info.c,v 1.24 2009-08-09 17:28:23 tcunha Exp $ */
22

33
/*
44
* Copyright (c) 2008 Nicholas Marriott <[email protected]>
@@ -56,6 +56,7 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
5656
struct tty_term_code_entry *ent;
5757
struct utsname un;
5858
struct grid *gd;
59+
struct grid_line *gl;
5960
u_int i, j, k;
6061
char out[80];
6162
char *tim;
@@ -120,15 +121,16 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
120121
lines = ulines = size = usize = 0;
121122
gd = wp->base.grid;
122123
for (k = 0; k < gd->hsize + gd->sy; k++) {
123-
if (gd->data[k] != NULL) {
124+
gl = &gd->linedata[k];
125+
if (gl->celldata != NULL) {
124126
lines++;
125-
size += gd->size[k] *
126-
sizeof (**gd->data);
127+
size += gl->cellsize *
128+
sizeof *gl->celldata;
127129
}
128-
if (gd->udata[k] != NULL) {
130+
if (gl->utf8data != NULL) {
129131
ulines++;
130-
usize += gd->usize[k] *
131-
sizeof (**gd->udata);
132+
usize += gl->utf8size *
133+
sizeof *gl->utf8data;
132134
}
133135
}
134136
ctx->print(ctx, "%6u: %s %lu %d %u/%u, %zu "

0 commit comments

Comments
 (0)