1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 12:00:31 +01:00

wrlib: Added clean-up of image cache in 'RShutdown'

The library maintains a cache of the images loaded, which is now
emptyed when the lib is asked to shutdown.
This commit is contained in:
David Maciejak
2014-05-08 23:57:02 +02:00
committed by Carlos R. Mafra
parent 283286e0cd
commit e237ec15a0
3 changed files with 24 additions and 0 deletions

View File

@@ -85,4 +85,10 @@ void RReleaseMagick(void);
Bool RSaveXPM(RImage *image, const char *file);
/*
* Function to terminate properly
*/
void RReleaseCache(void);
#endif

View File

@@ -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;

View File

@@ -251,4 +251,5 @@ void RShutdown(void)
#ifdef USE_MAGICK
RReleaseMagick();
#endif
RReleaseCache();
}