コード例 #1
0
ファイル: hikset.c プロジェクト: qgewfg/gtk-gnutella
static void
hikset_hash_free(struct hash *h)
{
	hikset_t *hx = HASH_IKSET(h);

	hikset_free_null(&hx);
}
コード例 #2
0
ファイル: hashlist.c プロジェクト: qgewfg/gtk-gnutella
/**
 * Dispose of the data structure, but not of the items it holds.
 *
 * @param hl_ptr	pointer to the variable containing the address of the list
 *
 * As a side effect, the variable containing the address of the list
 * is nullified, since it is no longer allowed to refer to the structure.
 */
void
hash_list_free(hash_list_t **hl_ptr)
{
	g_assert(NULL != hl_ptr);

	if (*hl_ptr) {
		hash_list_t *hl = *hl_ptr;
		link_t *lk, *next;

		hash_list_check(hl);

		if (--hl->refcount != 0) {
			g_carp("%s: hash list is still referenced! "
				"(hl=%p, hl->refcount=%d)",
				G_STRFUNC, cast_to_pointer(hl), hl->refcount);
		}

		hikset_free_null(&hl->ht);

		for (lk = elist_first(&hl->list); lk != NULL; lk = next) {
			struct hash_list_item *item = ITEM(lk);
			next = elist_next(lk);	/* Embedded, get next before freeing */
			WFREE(item);
		}

		elist_discard(&hl->list);
		hl->magic = 0;
		WFREE(hl);
		*hl_ptr = NULL;
	}
}
コード例 #3
0
ファイル: adns.c プロジェクト: lucab/gtk-gnutella
/**
 * Frees all memory allocated by the cache and returns NULL.
 */
static void
adns_cache_free(adns_cache_t **cache_ptr)
{
	adns_cache_t *cache = *cache_ptr;
	unsigned i;

	/* If adns is not used it will not be initialized */
	if (NULL == cache)
		return;

	g_assert(cache);
	g_assert(cache->ht);

	for (i = 0; i < G_N_ELEMENTS(cache->entries); i++) {
		adns_cache_free_entry(cache, i);
	}
	hikset_free_null(&cache->ht);
	XFREE_NULL(cache);
}
コード例 #4
0
/**
 * Shutdown the DHT publisher.
 */
void G_COLD
publisher_close(void)
{
	/*
	 * Purge data we no longer know about from the persisted DB.
	 */

	dbmw_foreach_remove(db_pubdata, publisher_remove_orphan, NULL);

	/*
	 * Final cleanup.
	 */

	hikset_foreach(publisher_sha1, free_entry, NULL);
	hikset_free_null(&publisher_sha1);

	dbstore_close(db_pubdata, settings_dht_db_dir(), db_pubdata_base);
	db_pubdata = NULL;

	cq_free_null(&publish_cq);
}
コード例 #5
0
ファイル: keys.c プロジェクト: lucab/gtk-gnutella
/**
 * Close local key management.
 */
G_GNUC_COLD void
keys_close(void)
{
	values_close();

	dbstore_close(db_keydata, settings_dht_db_dir(), db_keybase);
	db_keydata = NULL;

	if (keys) {
		hikset_foreach(keys, keys_free_kv, NULL);
		hikset_free_null(&keys);
	}

	kuid_atom_free_null(&kball.furthest);
	kuid_atom_free_null(&kball.closest);

	gnet_stats_set_general(GNR_DHT_KEYS_HELD, 0);
	gnet_stats_set_general(GNR_DHT_CACHED_KEYS_HELD, 0);

	cq_cancel(&kball_ev);
	cq_periodic_remove(&keys_periodic_ev);
	cq_periodic_remove(&keys_sync_ev);
}
コード例 #6
0
ファイル: aging.c プロジェクト: Eppo791906066/gtk-gnutella
/**
 * Destroy container, freeing all keys and values, and nullify pointer.
 */
void
aging_destroy(aging_table_t **ag_ptr)
{
	aging_table_t *ag = *ag_ptr;

	if (ag) {
		aging_check(ag);

		aging_synchronize(ag);

		hikset_foreach(ag->table, aging_free, ag);
		hikset_free_null(&ag->table);
		cq_periodic_remove(&ag->gc_ev);

		if (ag->lock != NULL) {
			mutex_destroy(ag->lock);
			WFREE(ag->lock);
		}

		ag->magic = 0;
		WFREE(ag);
		*ag_ptr = NULL;
	}
}