This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository legacy-imlib2.

View the commit online.

commit 50295779a17bea5a474fcb6a8defdc6a91310ee6
Author: NRK <n...@disroot.org>
AuthorDate: Mon Jul 3 09:03:40 2023 +0600

    introduce imlib_image_decache_file()
    
    Fixes: https://git.enlightenment.org/old/legacy-imlib2/issues/16
---
 src/lib/Imlib2.h.in |  9 +++++++++
 src/lib/api.c       |  6 ++++++
 src/lib/image.c     | 19 +++++++++++++++++++
 src/lib/image.h     |  1 +
 4 files changed, 35 insertions(+)

diff --git a/src/lib/Imlib2.h.in b/src/lib/Imlib2.h.in
index 0a2b768..66cc061 100644
--- a/src/lib/Imlib2.h.in
+++ b/src/lib/Imlib2.h.in
@@ -855,6 +855,15 @@ EAPI void           imlib_free_image(void);
  */
 EAPI void           imlib_free_image_and_decache(void);
 
+/**
+ * Invalidate all cached images associated with file
+ *
+ * @param file          filename to decache
+ *
+ * @return The number of images decached
+ */
+EAPI int            imlib_image_decache_file(const char *file);
+
 /*--------------------------------
  * Query/modify image parameters
  */
diff --git a/src/lib/api.c b/src/lib/api.c
index 07b7701..2496527 100644
--- a/src/lib/api.c
+++ b/src/lib/api.c
@@ -493,6 +493,12 @@ imlib_set_cache_size(int bytes)
    __imlib_SetCacheSize(bytes);
 }
 
+EAPI int
+imlib_image_decache_file(const char *file)
+{
+   return __imlib_DecacheFile(file);
+}
+
 EAPI void
 imlib_flush_loaders(void)
 {
diff --git a/src/lib/image.c b/src/lib/image.c
index c183859..663d22c 100644
--- a/src/lib/image.c
+++ b/src/lib/image.c
@@ -357,6 +357,25 @@ __imlib_GetCacheSize(void)
    return cache_size;
 }
 
+int
+__imlib_DecacheFile(const char *file)
+{
+   int                 n = 0;
+   ImlibImage         *im;
+
+   for (im = images; im; im = im->next)
+     {
+        if (!strcmp(file, im->file))
+          {
+             IM_FLAG_SET(im, F_INVALID);
+             ++n;
+          }
+     }
+   if (n > 0)
+      __imlib_CleanupImageCache();
+   return n;
+}
+
 /* Create a new image struct
  * If data is non-zero use it for pixel data, otherwise allocate the
  * pixel data buffer.
diff --git a/src/lib/image.h b/src/lib/image.h
index d527293..e472856 100644
--- a/src/lib/image.h
+++ b/src/lib/image.h
@@ -136,6 +136,7 @@ void                __imlib_FreeAllTags(ImlibImage * im);
 ImlibImageFrame    *__imlib_GetFrame(ImlibImage * im);
 
 void                __imlib_SetCacheSize(int size);
+int                 __imlib_DecacheFile(const char *file);
 int                 __imlib_GetCacheSize(void);
 int                 __imlib_CurrentCacheSize(void);
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to