Beispiel #1
0
static int insert__(bighash_table_t *table, int count, biglist_t** entries)
{
    int c;
    for(c = 0; c < count; c++) {
        test_entry_t *te = aim_zmalloc(sizeof(*te));
        te->id = c;

        bighash_insert(table, &te->hash_entry, hash_id(te->id));
        if(entries) {
            *entries = biglist_prepend(*entries, te);
        }
        /** Make sure we can find it */
        test_entry_t *fe = find_by_id(table, te->id);
        if(fe == NULL) {
            AIM_DIE("inserted entry was not found, count=%d/%d", c, count);
        }
        if(fe != te) {
            AIM_DIE("Retreived pointer not equal.");
        }
        if(bighash_entry_count(table) != (c+1)) {
            AIM_DIE("Entry count mismatch: should be %d, reported as %d",
                    (c+1), bighash_entry_count(table));
        }
    }
    return 0;
}
Beispiel #2
0
int
bighash_entries_move(bighash_table_t *dst, bighash_table_t *src)
{
    bighash_iter_t iter;
    bighash_entry_t *e;
    for(e = bighash_iter_start(src, &iter); e; e = bighash_iter_next(&iter)) {
        bighash_remove(src, e);
        bighash_insert(dst, e, e->hash);
    }
    return 0;
}