示例#1
0
void
magnet_resource_free(struct magnet_resource **res_ptr)
{
	struct magnet_resource *res = *res_ptr;

	if (res) {
		GSList *sl;

		atom_str_free_null(&res->display_name);
		atom_sha1_free_null(&res->sha1);
		atom_tth_free_null(&res->tth);
		atom_str_free_null(&res->parq_id);
		atom_str_free_null(&res->guid);
		atom_str_free_null(&res->vendor);

		for (sl = res->sources; sl != NULL; sl = g_slist_next(sl)) {
			struct magnet_source *ms = sl->data;
			magnet_source_free(&ms);
		}
		gm_slist_free_null(&res->sources);

		for (sl = res->searches; sl != NULL; sl = g_slist_next(sl)) {
			const char *s = sl->data;
			atom_str_free_null(&s);
		}
		gm_slist_free_null(&res->searches);
		wfree(res, sizeof *res);
		*res_ptr = NULL;
	}
}
示例#2
0
void
magnet_set_sha1(struct magnet_resource *res, const struct sha1 *sha1)
{
	const struct sha1 *atom;

	g_return_if_fail(res);
	g_return_if_fail(sha1);

	atom = atom_sha1_get(sha1);
	atom_sha1_free_null(&res->sha1);
	res->sha1 = atom;
}
示例#3
0
/**
 * Free publisher entry.
 */
static void
publisher_entry_free(struct publisher_entry *pe, bool do_remove)
{
	publisher_check(pe);

	if (do_remove) {
		hikset_remove(publisher_sha1, pe->sha1);
		delete_pubdata(pe->sha1);
	}

	if (pe->backgrounded)
		pdht_cancel_file(pe->sha1, FALSE);

	atom_sha1_free_null(&pe->sha1);
	cq_cancel(&pe->publish_ev);
	WFREE(pe);
}
示例#4
0
/**
 * Terminate THEX download.
 */
void
thex_download_free(struct thex_download **ptr)
{
	struct thex_download *ctx = *ptr;

	if (ctx) {
		if (ctx->rx) {
			rx_free(ctx->rx);
			ctx->rx = NULL;
		}
		HFREE_NULL(ctx->data);
		G_FREE_NULL(ctx->leaves);
		atom_sha1_free_null(&ctx->sha1);
		atom_tth_free_null(&ctx->tth);
		WFREE(ctx);
		*ptr = NULL;
	}
}
示例#5
0
void
magnet_source_free(struct magnet_source **ms_ptr)
{
	struct magnet_source *ms = *ms_ptr;
	
	if (ms) {
		atom_str_free_null(&ms->hostname);
		atom_str_free_null(&ms->path);
		atom_str_free_null(&ms->url);
		atom_sha1_free_null(&ms->sha1);
		atom_tth_free_null(&ms->tth);
		atom_guid_free_null(&ms->guid);
		if (ms->proxies) {
			free_proxies_list(ms->proxies);
			ms->proxies = NULL;
		}
		wfree(ms, sizeof *ms);
		*ms_ptr = NULL;
	}
}
示例#6
0
/**
 * Clear all the upload stats data structure.
 */
static G_GNUC_COLD void
upload_stats_free_all(void)
{
	if (upload_stats_list) {
		struct ul_stats *s;

		while (NULL != (s = hash_list_head(upload_stats_list))) {
			hash_list_remove(upload_stats_list, s);
			atom_str_free_null(&s->pathname);
			atom_str_free_null(&s->filename);
			if (s->sha1)
				g_hash_table_remove(upload_stats_by_sha1, s->sha1);
			atom_sha1_free_null(&s->sha1);
			WFREE(s);
		}
		hash_list_free(&upload_stats_list);
		gm_hash_table_destroy_null(&upload_stats_by_sha1);
	}
	dirty = TRUE;
}