From 7533684d8fa85c33756d18841f2bac5379f40f8b Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 15 Jul 2021 18:32:19 +0200 Subject: shm: add shm_get_many() - allows buffers to share a single pool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit shm_get_many() always returns new buffers (i.e. never old, cached ones). The newly allocated buffers are also marked for immediate purging, meaning they’ll be destroyed on the next call to either shm_get_buffer(), or shm_get_many(). Furthermore, we add a new attribute, ‘locked’, to the buffer struct. When auto purging buffers, look at this instead of comparing cookies. Buffer consumers are expected to set ‘locked’ while they hold a reference to it, and don’t want it destroyed behind their back. --- render.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'render.c') diff --git a/render.c b/render.c index 7d365643..37766232 100644 --- a/render.c +++ b/render.c @@ -2322,6 +2322,7 @@ grid_render(struct terminal *term) } if (term->render.last_buf != NULL) { + term->render.last_buf->locked = false; free(term->render.last_buf->scroll_damage); term->render.last_buf->scroll_damage = NULL; } @@ -2330,6 +2331,7 @@ grid_render(struct terminal *term) term->render.was_flashing = term->flash.active; term->render.was_searching = term->is_searching; + buf->locked = true; buf->age = 0; xassert(buf->scroll_damage == NULL); @@ -3416,6 +3418,8 @@ damage_view: tll_free(term->normal.scroll_damage); tll_free(term->alt.scroll_damage); + if (term->render.last_buf != NULL) + term->render.last_buf->locked = false; term->render.last_buf = NULL; term_damage_view(term); render_refresh_csd(term); -- cgit v1.3