/** test adding a random element */
static void
testremove(struct lruhash* table, testdata_t* ref[])
{
	int num = random() % HASHTESTMAX;
	testkey_t* key = newkey(num);
	lruhash_remove(table, myhash(num), key);
	ref[num] = NULL;
	delkey(key);
}
Example #2
0
//test remove a random element
static void testremove(struct lruhash *table, testdata *ref[])
{
    int num = random() % MAXHASH;
    testkey *key = newkey(num);
    lruhash_remove(table, simplehash(num), key);
    if (ref)
        ref[num] = NULL;
    delkey(key);
}
/** test adding a random element (unlimited range) */
static void
testremove_unlim(struct lruhash* table, testdata_t** ref)
{
	int num = random() % (HASHTESTMAX*10);
	testkey_t* key = newkey(num);
	lruhash_remove(table, myhash(num), key);
	if(ref)
		ref[num] = NULL;
	delkey(key);
}
/** test hashtable using short sequence */
static void
test_short_table(struct lruhash* table) 
{
	testkey_t* k = newkey(12);
	testkey_t* k2 = newkey(14);
	testdata_t* d = newdata(128);
	testdata_t* d2 = newdata(129);
	
	k->entry.data = d;
	k2->entry.data = d2;

	lruhash_insert(table, myhash(12), &k->entry, d, NULL);
	lruhash_insert(table, myhash(14), &k2->entry, d2, NULL);
	
	unit_assert( lruhash_lookup(table, myhash(12), k, 0) == &k->entry);
	lock_rw_unlock( &k->entry.lock );
	unit_assert( lruhash_lookup(table, myhash(14), k2, 0) == &k2->entry);
	lock_rw_unlock( &k2->entry.lock );
	lruhash_remove(table, myhash(12), k);
	lruhash_remove(table, myhash(14), k2);
}
Example #5
0
//test lruhash_insert, lruhash_lookup and lruhash_remove
static void test_short_table(struct lruhash *table)
{
    testkey *k1 = newkey(12);
    testkey *k2 = newkey(14);
    testdata *d1 = newdata(128);
    testdata *d2 = newdata(129);

    k1->entry.data = d1;
    k2->entry.data = d2;

    lruhash_insert(table, simplehash(12), &k1->entry, d1);
    lruhash_insert(table, simplehash(14), &k2->entry, d2);

    unit_assert(lruhash_lookup(table, simplehash(12), k1) == &k1->entry);
    lock_basic_unlock(&k1->entry.lock);

    unit_assert(lruhash_lookup(table, simplehash(14), k2) == &k2->entry);
    lock_basic_unlock(&k2->entry.lock );

    lruhash_remove(table, simplehash(12), k1);
    lruhash_remove(table, simplehash(14), k2);
}
Example #6
0
void slabhash_remove(struct slabhash* sl, hashvalue_type hash, void* key)
{
	lruhash_remove(sl->array[slab_idx(sl, hash)], hash, key);
}