From 8e5d386afc3c62c587d5e05ff111b41bdf421eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 2 Nov 2019 00:49:00 +0100 Subject: [PATCH] shm: add shm_purge() Destroys *all* buffers associated with the specified cookie. --- shm.c | 17 +++++++++++++++++ shm.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/shm.c b/shm.c index 6785cbfb..f58ca3e4 100644 --- a/shm.c +++ b/shm.c @@ -182,3 +182,20 @@ shm_fini(void) tll_remove(buffers, it); } } + +void +shm_purge(struct wl_shm *shm, unsigned long cookie) +{ + LOG_DBG("cookie=%lx: purging all buffers", cookie); + + /* Purge old buffers associated with this cookie */ + tll_foreach(buffers, it) { + if (it->item.cookie != cookie) + continue; + + assert(!it->item.busy); + + buffer_destroy(&it->item); + tll_remove(buffers, it); + } +} diff --git a/shm.h b/shm.h index 555c5d51..cec0ef81 100644 --- a/shm.h +++ b/shm.h @@ -24,3 +24,5 @@ struct buffer { struct buffer *shm_get_buffer( struct wl_shm *shm, int width, int height, unsigned long cookie); void shm_fini(void); + +void shm_purge(struct wl_shm *shm, unsigned long cookie);