From: David Maciejak <[email protected]>
The library maintains a cache of the images loaded, which is now
emptyed when the lib is asked to shutdown.
---
wrlib/imgformat.h | 6 ++++++
wrlib/load.c | 17 +++++++++++++++++
wrlib/misc.c | 1 +
3 files changed, 24 insertions(+)
diff --git a/wrlib/imgformat.h b/wrlib/imgformat.h
index 004da30..6bb0610 100644
--- a/wrlib/imgformat.h
+++ b/wrlib/imgformat.h
@@ -85,4 +85,10 @@ void RReleaseMagick(void);
Bool RSaveXPM(RImage *image, const char *file);
+/*
+ * Function to terminate properly
+ */
+void RReleaseCache(void);
+
+
#endif
diff --git a/wrlib/load.c b/wrlib/load.c
index 4475070..7c2e6af 100644
--- a/wrlib/load.c
+++ b/wrlib/load.c
@@ -129,6 +129,23 @@ static void init_cache(void)
}
}
+void RReleaseCache(void)
+{
+ int i;
+
+ if (RImageCacheSize > 0) {
+ for (i = 0; i < RImageCacheSize; i++) {
+ if (RImageCache[i].file) {
+ RReleaseImage(RImageCache[i].image);
+ free(RImageCache[i].file);
+ }
+ }
+ free(RImageCache);
+ RImageCache = NULL;
+ RImageCacheSize = -1;
+ }
+}
+
RImage *RLoadImage(RContext * context, const char *file, int index)
{
RImage *image = NULL;
diff --git a/wrlib/misc.c b/wrlib/misc.c
index 00a7c57..53d5aaa 100644
--- a/wrlib/misc.c
+++ b/wrlib/misc.c
@@ -251,4 +251,5 @@ void RShutdown(void)
#ifdef USE_MAGICK
RReleaseMagick();
#endif
+ RReleaseCache();
}
--
1.9.2
--
To unsubscribe, send mail to [email protected].