From 2e1a07913df741c1c4eac7d855bf0b1171e0b436 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sat, 6 Jul 2019 20:37:30 +0000 Subject: Correctly clear underscore colour in grid_get_cell1, also fix struct grid_cell to avoid padding. Fixes increased memory use reported by Suraj N Kurapati. --- usr.bin/tmux/format-draw.c | 4 ++-- usr.bin/tmux/grid.c | 7 ++++--- usr.bin/tmux/screen-write.c | 4 ++-- usr.bin/tmux/style.c | 4 ++-- usr.bin/tmux/tmux.h | 8 ++++---- 5 files changed, 14 insertions(+), 13 deletions(-) (limited to 'usr.bin/tmux') diff --git a/usr.bin/tmux/format-draw.c b/usr.bin/tmux/format-draw.c index c74f2841a99..d1023deb1c3 100644 --- a/usr.bin/tmux/format-draw.c +++ b/usr.bin/tmux/format-draw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format-draw.c,v 1.11 2019/07/01 06:56:00 nicm Exp $ */ +/* $OpenBSD: format-draw.c,v 1.12 2019/07/06 20:37:29 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott @@ -565,7 +565,7 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base, cp++; } - /* Draw the cell to th current screen. */ + /* Draw the cell to the current screen. */ screen_write_cell(&ctx[current], &sy.gc); width[current] += ud->width; continue; diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c index 3e75f8f6076..878e4b22a43 100644 --- a/usr.bin/tmux/grid.c +++ b/usr.bin/tmux/grid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grid.c,v 1.96 2019/06/27 15:17:41 nicm Exp $ */ +/* $OpenBSD: grid.c,v 1.97 2019/07/06 20:37:29 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -37,12 +37,12 @@ /* Default grid cell data. */ const struct grid_cell grid_default_cell = { - 0, 0, 8, 8, 0, { { ' ' }, 0, 1, 1 } + { { ' ' }, 0, 1, 1 }, 0, 0, 8, 8, 0 }; /* Cleared grid cell data. */ const struct grid_cell grid_cleared_cell = { - GRID_FLAG_CLEARED, 0, 8, 8, 0, { { ' ' }, 0, 1, 1 } + { { ' ' }, 0, 1, 1 }, 0, GRID_FLAG_CLEARED, 8, 8, 0 }; static const struct grid_cell_entry grid_cleared_entry = { GRID_FLAG_CLEARED, { .data = { 0, 8, 8, ' ' } } @@ -475,6 +475,7 @@ grid_get_cell1(struct grid_line *gl, u_int px, struct grid_cell *gc) gc->bg = gce->data.bg; if (gce->flags & GRID_FLAG_BG256) gc->bg |= COLOUR_FLAG_256; + gc->us = 0; utf8_set(&gc->data, gce->data.data); } diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index 07bbc29eea7..d782a12b0e1 100644 --- a/usr.bin/tmux/screen-write.c +++ b/usr.bin/tmux/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.154 2019/06/27 15:17:41 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.155 2019/07/06 20:37:29 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -36,7 +36,7 @@ static const struct grid_cell *screen_write_combine(struct screen_write_ctx *, const struct utf8_data *, u_int *); static const struct grid_cell screen_write_pad_cell = { - GRID_FLAG_PADDING, 0, 8, 8, 0, { { 0 }, 0, 0, 0 } + { { 0 }, 0, 0, 0 }, 0, GRID_FLAG_PADDING, 0, 8, 8 }; struct screen_write_collect_item { diff --git a/usr.bin/tmux/style.c b/usr.bin/tmux/style.c index 887036ef280..8bc0fd4c812 100644 --- a/usr.bin/tmux/style.c +++ b/usr.bin/tmux/style.c @@ -1,4 +1,4 @@ -/* $OpenBSD: style.c,v 1.22 2019/07/01 06:56:00 nicm Exp $ */ +/* $OpenBSD: style.c,v 1.23 2019/07/06 20:37:29 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -30,7 +30,7 @@ /* Default style. */ static struct style style_default = { - { 0, 0, 8, 8, 0, { { ' ' }, 0, 1, 1 } }, + { { { ' ' }, 0, 1, 1 }, 0, 0, 8, 8, 0 }, 8, STYLE_ALIGN_DEFAULT, diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 74b1c28d051..010bed577cf 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.918 2019/07/01 06:56:00 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.919 2019/07/06 20:37:29 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -596,13 +596,13 @@ enum utf8_state { /* Grid cell data. */ struct grid_cell { - u_char flags; + struct utf8_data data; /* 21 bytes */ u_short attr; + u_char flags; int fg; int bg; int us; - struct utf8_data data; -}; +} __packed; struct grid_cell_entry { u_char flags; union { -- cgit v1.2.3