From 53a43cb38838bd65512b3b8902cc8a3ecfaaca56 Mon Sep 17 00:00:00 2001 From: NRK Date: Sun, 2 Jul 2023 20:15:53 +0600 Subject: introduce img_free() this removes some repetitive code. --- thumbs.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'thumbs.c') diff --git a/thumbs.c b/thumbs.c index d5a6c6b..d2f91a7 100644 --- a/thumbs.c +++ b/thumbs.c @@ -179,12 +179,8 @@ CLEANUP void tns_free(tns_t *tns) int i; if (tns->thumbs != NULL) { - for (i = 0; i < *tns->cnt; i++) { - if (tns->thumbs[i].im != NULL) { - imlib_context_set_image(tns->thumbs[i].im); - imlib_free_image(); - } - } + for (i = 0; i < *tns->cnt; i++) + img_free(tns->thumbs[i].im, false); free(tns->thumbs); tns->thumbs = NULL; } @@ -233,12 +229,8 @@ bool tns_load(tns_t *tns, int n, bool force, bool cache_only) return false; t = &tns->thumbs[n]; - - if (t->im != NULL) { - imlib_context_set_image(t->im); - imlib_free_image(); - t->im = NULL; - } + img_free(t->im, false); + t->im = NULL; if (!force) { if ((im = tns_cache_load(file->path, &force)) != NULL) { @@ -363,11 +355,8 @@ void tns_unload(tns_t *tns, int n) assert(n >= 0 && n < *tns->cnt); t = &tns->thumbs[n]; - if (t->im != NULL) { - imlib_context_set_image(t->im); - imlib_free_image(); - t->im = NULL; - } + img_free(t->im, false); + t->im = NULL; } static void tns_check_view(tns_t *tns, bool scrolled) -- cgit v1.2.3-54-g00ecf