/* * Free memory allocated for entire hash table */ void free_table(struct hash_entry** table) { struct hash_entry* e; int i; if (!table) return; for(i = 0; i < HASH_SIZE; i++) { while(table[i]) { e = table[i]; table[i] = table[i]->next; free_hash_entry(e); } } }
/** * Helper func for stats_display - * does two things: * * - clears out aged / infrequent search terms * - sticks the rest of the search terms in treeview_search_stats */ static bool stats_hash_to_treeview(const void *key, void *value, void *unused_udata) { struct term_counts *val = value; GtkTreeIter iter; char *s; (void) unused_udata; /* update counts */ val->periods = val->period_cnt ? 0 : (val->periods + 1); val->total_cnt += val->period_cnt; /* try to keep the number of infrequent terms down */ if ( (1.0 * val->total_cnt / (val->periods + 2.0)) * 100 < GUI_PROPERTY(search_stats_delcoef) ) { free_hash_entry(key, value, NULL); return TRUE; } stat_count++; /* update the display */ s = key ? unknown_to_utf8_normalized(key, UNI_NORM_GUI, NULL) : NULL; gtk_list_store_append(store_search_stats, &iter); gtk_list_store_set(store_search_stats, &iter, 0, s, 1, (gulong) val->period_cnt, 2, (gulong) val->total_cnt, (-1)); if (key != s) { G_FREE_NULL(s); } /* new period begins */ val->period_cnt = 0; return FALSE; }