Ejemplo n.º 1
0
/**
 * Clear specified hash table.
 */
static void
dh_table_clear(htable_t *ht)
{
	g_assert(ht != NULL);

	htable_foreach_remove(ht, free_muid_true, NULL);
}
Ejemplo n.º 2
0
/**
 * Iterate over the map, applying callback on each item and removing it if
 * the callback returns TRUE.
 *
 * @return the amount of items deleted.
 */
size_t
map_foreach_remove(const map_t *m, keyval_rm_fn_t cb, void *u)
{
	map_check(m);
	g_assert(cb);

	switch (m->type) {
	case MAP_HASH:
		return htable_foreach_remove(m->u.ht, (ckeyval_rm_fn_t) cb, u);
	case MAP_ORDERED_HASH:
		return ohash_table_foreach_remove(m->u.ot, cb, u);
	case MAP_PATRICIA:
		{
			struct pat_foreach_remove ctx;

			ctx.cb = cb;
			ctx.u = u;

			return patricia_foreach_remove(
				m->u.pt, pat_foreach_remove_wrapper, &ctx);
		}
	case MAP_MAXTYPE:
		g_assert_not_reached();
	}
	return 0;
}
Ejemplo n.º 3
0
/* this sucks -- too slow */
static void
empty_hash_table(void)
{
    if (!stat_hash)
        return;

    htable_foreach_remove(stat_hash, free_hash_entry, NULL);
}
Ejemplo n.º 4
0
/**
 * Display the data gathered during the last time period.
 * Perhaps it would be better to have this done on a button click(?)
 */
static void
search_stats_gui_update_display(void)
{
    gboolean sorting_disabled;
    tm_t start_time, end_time;
    time_delta_t elapsed;

    stat_count = 0;
    g_object_freeze_notify(G_OBJECT(treeview_search_stats));
    gtk_list_store_clear(store_search_stats);

    /*
     * Temporarily disable sorting while inserting the updated table.
     * Otherwise, CPU is overloaded with sorting every addition
     *  to the hash table.
     */
    sorting_disabled = FALSE;
    tm_now_exact(&start_time);
    if (store_search_stats->sort_column_id >= 0) {
        sorting_disabled = TRUE;
        search_stats_gui_sort_save();
    }
    /* insert the hash table contents into the sorted treeview */
    htable_foreach_remove(stat_hash, stats_hash_to_treeview, NULL);

    tm_now_exact(&end_time);
    elapsed = tm_elapsed_ms(&end_time, &start_time);

    /*
     * Re-enable sorting if previously disabled.
     * If too much time has elapsed, leave sorting disabled.
     */
    if (sorting_disabled && elapsed < 100) {
        search_stats_gui_sort_restore();
    } else if (!sorting_disabled && elapsed > 200) {
        /*
         * If sorting is disabled, and too much time is still elapsing,
         * then the search stats collection will need to be
         * discontinued
         */
        search_stats_gui_reset();
        search_stats_gui_disable();
        search_stats_gui_overload = TRUE;
    }

    if (search_stats_gui_overload) {
        /* update status bar message */
        gtk_label_set_text(GTK_LABEL(label_search_stats_count),
                           "Disabling Search Stats due to system load" );
    } else {
        /* update the status bar counter */
        gtk_label_printf(GTK_LABEL(label_search_stats_count),
                         NG_("%u term counted", "%u terms counted", stat_count),
                         stat_count);
    }
    g_object_thaw_notify(G_OBJECT(treeview_search_stats));
}
Ejemplo n.º 5
0
/**
 * Free specified hash table.
 */
static void
dh_table_free(htable_t **ptr)
{
	if (*ptr) {
		htable_t *ht = *ptr;
		htable_foreach_remove(ht, free_muid_true, NULL);
		htable_free_null(ptr);
	}
}
Ejemplo n.º 6
0
/**
 * Reset header object, for new header parsing.
 */
void
header_reset(header_t *o)
{
	header_check(o);

	if (o->headers != NULL) {
		htable_foreach_remove(o->headers, free_header_data, NULL);
		htable_free_null(&o->headers);
	}
	slist_free_all(&o->fields, cast_to_free_fn(hfield_free));
	o->flags = o->size = o->num_lines = 0;
}
Ejemplo n.º 7
0
void
fi_gui_clear_sources(void)
{
    gtk_list_store_clear(store_sources);
	htable_foreach_remove(fi_sources, fi_sources_remove, NULL);
}