mirror of
https://github.com/tmux/tmux.git
synced 2026-02-25 04:15:04 +00:00
Reuse extended entry when clearing RGB cell, to prevent memory growth
when cells are repeatedly cleared (they are only compacted when scrolled off screen). From Michael K Darling in GitHub issue 4862.
This commit is contained in:
8
grid.c
8
grid.c
@@ -205,11 +205,17 @@ grid_clear_cell(struct grid *gd, u_int px, u_int py, u_int bg)
|
||||
struct grid_line *gl = &gd->linedata[py];
|
||||
struct grid_cell_entry *gce = &gl->celldata[px];
|
||||
struct grid_extd_entry *gee;
|
||||
u_int old_offset = gce->offset;
|
||||
int had_extd = (gce->flags & GRID_FLAG_EXTENDED);
|
||||
|
||||
memcpy(gce, &grid_cleared_entry, sizeof *gce);
|
||||
if (bg != 8) {
|
||||
if (bg & COLOUR_FLAG_RGB) {
|
||||
grid_get_extended_cell(gl, gce, gce->flags);
|
||||
if (had_extd && old_offset < gl->extdsize) {
|
||||
gce->flags |= GRID_FLAG_EXTENDED;
|
||||
gce->offset = old_offset;
|
||||
} else
|
||||
grid_get_extended_cell(gl, gce, gce->flags);
|
||||
gee = grid_extended_cell(gl, gce, &grid_cleared_cell);
|
||||
gee->bg = bg;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user