From: Kaj-Michael Lang Date: Fri, 25 Apr 2008 10:11:46 +0000 (+0300) Subject: Add function to set cache size X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d21c2cde74adfdbd08ed6ebcae6c08ce60a15b2;p=mapper Add function to set cache size --- diff --git a/src/image-cache.c b/src/image-cache.c index 0b384fc..56836ee 100644 --- a/src/image-cache.c +++ b/src/image-cache.c @@ -20,6 +20,17 @@ g_hash_table_destroy(ic->cache); g_slice_free(ImageCache, ic); } +void +image_cache_set_size(ImageCache *ic, guint cache_size) +{ +guint old; + +old=ic->cache_max; +ic->cache_max=cache_size; +if (old>cache_size) + image_cache_gc(ic, cache_size); +} + static void image_cache_stats(ImageCache *ic) { diff --git a/src/image-cache.h b/src/image-cache.h index 15ccd1f..9bc7130 100644 --- a/src/image-cache.h +++ b/src/image-cache.h @@ -23,6 +23,7 @@ struct _image_cache { ImageCache *image_cache_new(guint cache_max); void image_cache_free(ImageCache *ic); void image_cache_clear(ImageCache *ic); +void image_cache_set_size(ImageCache *ic, guint cache_size); void image_cache_gc(ImageCache *ic, gint max); void image_cache_invalidate(ImageCache *ic, const gchar *key); void image_cache_invalidate_by_image(ImageCache *ic, GdkPixbuf *pixbuf);