mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-18 20:10:29 +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:
committed by
Carlos R. Mafra
parent
283286e0cd
commit
e237ec15a0
@@ -85,4 +85,10 @@ void RReleaseMagick(void);
|
|||||||
Bool RSaveXPM(RImage *image, const char *file);
|
Bool RSaveXPM(RImage *image, const char *file);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function to terminate properly
|
||||||
|
*/
|
||||||
|
void RReleaseCache(void);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
17
wrlib/load.c
17
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 *RLoadImage(RContext * context, const char *file, int index)
|
||||||
{
|
{
|
||||||
RImage *image = NULL;
|
RImage *image = NULL;
|
||||||
|
|||||||
@@ -251,4 +251,5 @@ void RShutdown(void)
|
|||||||
#ifdef USE_MAGICK
|
#ifdef USE_MAGICK
|
||||||
RReleaseMagick();
|
RReleaseMagick();
|
||||||
#endif
|
#endif
|
||||||
|
RReleaseCache();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user