示例#1
0
void *ds_hash_remove(ds_hash_t *t, void *e)
{
    int bucket;
    ds_list_t *chain;
    void *result;

    CODA_ASSERT(DS_HASH_VALID(t));
    bucket = (t->hfn(e)) % t->nbuckets;
    chain  = (t->buckets)[bucket];
    result = ds_list_remove(chain, e);
    if (result != NULL)
        t->count--;
    return result;
}
示例#2
0
void ds_stopwatch_free(ds_stopwatch *stopwatch)
{
	ds_list *list;

	DS_ASSERT(!stopwatch);

	list = &stopwatch->times_head;
	while (!ds_list_empty(&stopwatch->times_head)) {
		struct _ds_stopwatch_record *record;

		list = ds_list_next(list);
		ds_list_remove(list);
		record = ds_list_get_list_data(list);
		free(record);
		ds_list_free(list);
	}

	ds_list_deinit(&stopwatch->times_head);
	free(stopwatch);
}
示例#3
0
void ds_stopwatch_clear(ds_stopwatch *stopwatch)
{
	ds_list *list = NULL;

	DS_ASSERT(!stopwatch);

	list = &stopwatch->times_head;
	while (!ds_list_empty(&stopwatch->times_head)) {
		struct _ds_stopwatch_record *record;

		list = ds_list_next(list);
		ds_list_remove(list);
		record = ds_list_get_list_data(list);
		free(record);
		ds_list_free(list);
	}
	stopwatch->current_start = 0;
	stopwatch->current_stop = 0;
	stopwatch->total_lapse = 0;
	stopwatch->count = 0;
}