static void ep_finalise(GObject *o) { EEvent *emp = (EEvent *)o; struct _EEventPrivate *p = emp->priv; struct _event_node *node; if (emp->target) e_event_target_free(emp, emp->target); g_free(emp->id); while ((node = (struct _event_node *)e_dlist_remhead(&p->events))) { if (node->freefunc) node->freefunc(emp, node->events, node->data); g_free(node); } g_slist_foreach(p->sorted, (GFunc)g_free, NULL); g_slist_free(p->sorted); g_free(p); ((GObjectClass *)ep_parent)->finalize(o); }
/** * em_cache_clear: * @emc: * * clear the cache. just for api completeness. **/ void em_cache_clear(EMCache *emc) { EMCacheNode *node; EDList old_nodes; e_dlist_init(&old_nodes); g_mutex_lock(emc->lock); while ((node = (EMCacheNode *)e_dlist_remhead(&emc->lru_list))) e_dlist_addtail(&old_nodes, (EDListNode *)node); g_mutex_unlock(emc->lock); while ((node = (EMCacheNode *)e_dlist_remhead(&old_nodes))) { emc->node_free(node); g_free(node->key); g_free(node); } }
static void camel_offline_journal_finalize (CamelObject *object) { CamelOfflineJournal *journal = (CamelOfflineJournal *) object; EDListNode *entry; g_free (journal->filename); while ((entry = e_dlist_remhead (&journal->queue))) CAMEL_OFFLINE_JOURNAL_GET_CLASS (journal)->entry_free (journal, entry); }
/** * em_cache_add: * @emc: * @n: * * Add a cache node to the cache, once added the memory is owned by * the cache. If there are conflicts and the old node is still in * use, then the new node is not added, otherwise it is added and any * nodes older than the expire time are flushed. **/ void em_cache_add(EMCache *emc, EMCacheNode *n) { EMCacheNode *old, *prev; EDList old_nodes; e_dlist_init(&old_nodes); g_mutex_lock(emc->lock); old = g_hash_table_lookup(emc->key_table, n->key); if (old != NULL) { if (old->ref_count == 0) { g_hash_table_remove(emc->key_table, old->key); e_dlist_remove((EDListNode *)old); e_dlist_addtail(&old_nodes, (EDListNode *)old); goto insert; } else { e_dlist_addtail(&old_nodes, (EDListNode *)n); } } else { time_t now; insert: now = time(0); g_hash_table_insert(emc->key_table, n->key, n); e_dlist_addhead(&emc->lru_list, (EDListNode *)n); n->stamp = now; emc->node_count++; c(printf("inserting node %s\n", n->key)); old = (EMCacheNode *)emc->lru_list.tailpred; prev = old->prev; while (prev && old->stamp < now - emc->timeout) { if (old->ref_count == 0) { c(printf("expiring node %s\n", old->key)); g_hash_table_remove(emc->key_table, old->key); e_dlist_remove((EDListNode *)old); e_dlist_addtail(&old_nodes, (EDListNode *)old); } old = prev; prev = prev->prev; } } g_mutex_unlock(emc->lock); while ((old = (EMCacheNode *)e_dlist_remhead(&old_nodes))) { emc->node_free(old); g_free(old->key); g_free(old); } }