Exemple #1
0
int
main(int argc, char **argv)
{
	struct lru_tree_s *lt;

	(void) argc;
	(void) argv;

	lt = lru_tree_create((GCompareFunc)g_strcmp0, g_free, NULL, 0);
	g_assert(lt != NULL);

	lru_tree_insert(lt, g_strdup("plop"), GINT_TO_POINTER(1));
	lru_tree_insert(lt, g_strdup("plop"), GINT_TO_POINTER(1));
	lru_tree_insert(lt, g_strdup("plip"), GINT_TO_POINTER(1));
	lru_tree_insert(lt, g_strdup("plup"), GINT_TO_POINTER(1));
	lru_tree_get(lt, "plop");
	lru_tree_get(lt, "plop");
	lru_tree_get(lt, "plop");
	lru_tree_get(lt, "plop");

	gpointer k, v;
	while (lru_tree_steal_first(lt, &k, &v)) {
		g_printerr("K %s %p\n", (gchar*)k, v);
		g_free(k);
	}

	lru_tree_destroy(lt);
	return 0;
}
Exemple #2
0
struct hc_resolver_s*
hc_resolver_create1(time_t now)
{
	struct hc_resolver_s *resolver = g_malloc0(sizeof(struct hc_resolver_s));

	resolver->csm0.max = HC_RESOLVER_DEFAULT_MAX_CSM0;
	resolver->csm0.ttl = HC_RESOLVER_DEFAULT_TTL_CSM0;
	resolver->csm0.cache = lru_tree_create((GCompareFunc)hashstr_quick_cmp,
			g_free, g_free, 0);

	resolver->services.max = HC_RESOLVER_DEFAULT_MAX_SERVICES;
	resolver->services.ttl = HC_RESOLVER_DEFAULT_TTL_SERVICES;
	resolver->services.cache = lru_tree_create((GCompareFunc)hashstr_quick_cmp,
			g_free, g_free, 0);

	resolver->bogonow = now;
	resolver->lock = g_mutex_new();
	return resolver;
}
Exemple #3
0
static struct lru_tree_s *
_push_queue_create (void)
{
	return lru_tree_create((GCompareFunc)g_strcmp0, g_free,
			(GDestroyNotify) service_info_clean, LTO_NOATIME);
}