Beispiel #1
0
void hash_table_foreach(hash_table_t *ht,
                        int (*foreach_cb)(void *data, void *cbarg), void *cbarg)
{
    hash_node_t *node;
    hash_node_t *next;
    hash_node_t **prev;
    int i;
    int rv;

    for (i = 0; i < ht->size; i++) {
        node = ht->nodes[i];
        prev = &ht->nodes[i];
        while (node) {
            next = node->next;
            rv = foreach_cb(node->data, cbarg);
            if (rv == hash_table_foreach_delete) {
                *prev = next;
                free(node);
                ht->count--;
            } else {
                prev = &node->next;
            }
            node = next;
        }
    }
}
Beispiel #2
0
void      gib_hash_foreach(gib_hash *hash, void (*foreach_cb)(gib_hash_node *node, void *data), void *data)
{
	gib_hash_node *i, *next;
	for (i=hash->base; i; i=next) {
		next = GIB_HASH_NODE(GIB_LIST(i)->next);
		foreach_cb(i,data);
	}
	return;
}