X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-cache-mgr.c;h=c5bf3cbd2b71314d85e94074d5c239d8a441872d;hp=6e64be6dd6d9763f717114f7a6bc45060cdba298;hb=f6f92ad4c90e26c23355ca3909c110aff01129b9;hpb=fd54149b68b3777ce63ebf25346bbc485cd84ec8 diff --git a/src/modest-cache-mgr.c b/src/modest-cache-mgr.c index 6e64be6..c5bf3cb 100644 --- a/src/modest-cache-mgr.c +++ b/src/modest-cache-mgr.c @@ -29,6 +29,7 @@ #include #include +#include /* 'private'/'protected' functions */ static void modest_cache_mgr_class_init (ModestCacheMgrClass *klass); @@ -128,7 +129,6 @@ modest_cache_mgr_init (ModestCacheMgr *obj) g_direct_equal, (GDestroyNotify)my_object_unref, /* ref'd GObject */ (GDestroyNotify)my_object_unref); /* ref'd GObject */ - } @@ -142,7 +142,7 @@ modest_cache_mgr_finalize (GObject *obj) priv = MODEST_CACHE_MGR_GET_PRIVATE(obj); modest_cache_mgr_flush_all (self); - + priv->date_str_cache = NULL; priv->display_str_cache = NULL; priv->pixbuf_cache = NULL; @@ -183,6 +183,11 @@ modest_cache_mgr_get_cache (ModestCacheMgr* self, ModestCacheMgrCacheType type GHashTable *cache; g_return_val_if_fail (self, NULL); + + if (!(type >= 0 && type <= MODEST_CACHE_MGR_CACHE_TYPE_NUM)) { + printf ("DEBUG: %s: incorrect type = %d\n", __FUNCTION__, type); + } + g_return_val_if_fail (type >= 0 && type <= MODEST_CACHE_MGR_CACHE_TYPE_NUM, NULL); priv = MODEST_CACHE_MGR_GET_PRIVATE(self); @@ -192,13 +197,6 @@ modest_cache_mgr_get_cache (ModestCacheMgr* self, ModestCacheMgrCacheType type } -static gboolean -always_true (gpointer key, gpointer value, gpointer user_data) -{ - return TRUE; -} - - void modest_cache_mgr_flush (ModestCacheMgr *self, ModestCacheMgrCacheType type) { @@ -207,13 +205,12 @@ modest_cache_mgr_flush (ModestCacheMgr *self, ModestCacheMgrCacheType type) g_return_if_fail (self); g_return_if_fail (type >= 0 && type <= MODEST_CACHE_MGR_CACHE_TYPE_NUM); - + priv = MODEST_CACHE_MGR_GET_PRIVATE(self); cache = get_cache (priv, type); if (cache) - g_hash_table_foreach_remove (cache, always_true, NULL); - /* g_hash_table_remove_all (cache) in only available since GLIB 2.12 */ + g_hash_table_destroy (cache); } @@ -222,7 +219,7 @@ modest_cache_mgr_flush_all (ModestCacheMgr *self) { int i; g_return_if_fail (self); - + for (i = 0; i != MODEST_CACHE_MGR_CACHE_TYPE_NUM; ++i) modest_cache_mgr_flush (self, i); }