Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4348 → Rev 4343

/branches/dynload/kernel/generic/src/adt/hash_table.c
32,7 → 32,7
 
/**
* @file
* @brief Implementation of generic chained hash table.
* @brief Implementation of generic chained hash table.
*
* This file contains implementation of generic chained hash table.
*/
56,15 → 56,13
index_t i;
 
ASSERT(h);
ASSERT(op);
ASSERT(op->hash);
ASSERT(op->compare);
ASSERT(op && op->hash && op->compare);
ASSERT(max_keys > 0);
h->entry = (link_t *) malloc(m * sizeof(link_t), 0);
if (!h->entry)
if (!h->entry) {
panic("Cannot allocate memory for hash table.");
}
memsetb(h->entry, m * sizeof(link_t), 0);
for (i = 0; i < m; i++)
84,13 → 82,10
void hash_table_insert(hash_table_t *h, unative_t key[], link_t *item)
{
index_t chain;
 
ASSERT(item);
ASSERT(h);
ASSERT(h->op);
ASSERT(h->op->hash);
ASSERT(h->op->compare);
ASSERT(h && h->op && h->op->hash && h->op->compare);
 
chain = h->op->hash(key);
ASSERT(chain < h->entries);
108,12 → 103,9
{
link_t *cur;
index_t chain;
ASSERT(h);
ASSERT(h->op);
ASSERT(h->op->hash);
ASSERT(h->op->compare);
 
ASSERT(h && h->op && h->op->hash && h->op->compare);
 
chain = h->op->hash(key);
ASSERT(chain < h->entries);
131,7 → 123,7
 
/** Remove all matching items from hash table.
*
* For each removed item, h->remove_callback() is called (if not NULL).
* For each removed item, h->remove_callback() is called.
*
* @param h Hash table.
* @param key Array of keys that will be compared against items of the hash table.
141,15 → 133,12
{
index_t chain;
link_t *cur;
ASSERT(h);
ASSERT(h->op);
ASSERT(h->op->hash);
ASSERT(h->op->compare);
 
ASSERT(h && h->op && h->op->hash && h->op->compare && h->op->remove_callback);
ASSERT(keys <= h->max_keys);
if (keys == h->max_keys) {
 
/*
* All keys are known, hash_table_find() can be used to find the entry.
*/
157,8 → 146,7
cur = hash_table_find(h, key);
if (cur) {
list_remove(cur);
if (h->op->remove_callback)
h->op->remove_callback(cur);
h->op->remove_callback(cur);
}
return;
}
176,8 → 164,7
cur = cur->prev;
list_remove(hlp);
if (h->op->remove_callback)
h->op->remove_callback(hlp);
h->op->remove_callback(hlp);
continue;
}