Ejemplo n.º 1
0
/**
 * Get a version token for the short version string, base64-encoded.
 *
 * @returns a pointer to static data.
 */
char *
tok_short_version(void)
{
	static time_t last_generated = 0;
	static char *toklevel = NULL;
	time_t now = tm_time();

	/*
	 * We don't generate a new token each time, but only every TOKEN_LIFE
	 * seconds.  The clock skew threshold must be greater than twice that
	 * amount, of course.
	 */

	g_assert(TOKEN_CLOCK_SKEW > 2 * TOKEN_LIFE);

	if (delta_time(now, last_generated) < TOKEN_LIFE)
		return toklevel;

	last_generated = now;

	G_FREE_NULL(toklevel);
	toklevel = tok_generate(now, version_short_string);

	return NOT_LEAKING(toklevel);
}
Ejemplo n.º 2
0
static const char *
tth_cache_directory(void)
{
	static char *directory;

	if (!directory) {
		directory = make_pathname(settings_config_dir(), "tth_cache");
	}
	return NOT_LEAKING(directory);
}
Ejemplo n.º 3
0
/**
 * Set the internal name of the column without changing the
 * column header widget. (Copy paste internal column_title_new
 * from gtkclist.c)
 *
 * @warning EVIL HACK
 */
void
gtk_clist_set_column_name(GtkCList *clist, int col, const char *title)
{
    if (col >= 0 && col < clist->columns) {
		if (
			NULL == title ||
			NULL == clist->column[col].title ||
			0 != strcmp(clist->column[col].title, title)
		) {
			G_FREE_NULL(clist->column[col].title);
			clist->column[col].title = NOT_LEAKING(g_strdup(title));
		}
	}
}
Ejemplo n.º 4
0
/**
 * Initialize the spinlock array, once.
 */
static void
pio_init_once(void)
{
	unsigned i;

	g_assert(NULL == pio_locks);

	pio_capacity = getdtablesize();
	XMALLOC_ARRAY(pio_locks, pio_capacity);
	(void) NOT_LEAKING(pio_locks);

	for (i = 0; i < pio_capacity; i++) {
		spinlock_init(&pio_locks[i]);
	}
}
Ejemplo n.º 5
0
/**
 * Clear all upload statistic entries from the GtkTreeModel.
 *
 */
void
upload_stats_gui_clear_model(void)
{
	GtkListStore *store;

	store = GTK_LIST_STORE(gtk_tree_view_get_model(upload_stats_treeview));
	if (store) {
		gtk_list_store_clear(store);
	}
	if (ht_uploads) {
		htable_foreach(ht_uploads, free_upload_data, NULL);
		htable_free_null(&ht_uploads);
		ht_uploads = NOT_LEAKING(htable_create(HASH_KEY_SELF, 0));
	}
}