Rev 790 | Rev 814 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 790 | Rev 792 | ||
---|---|---|---|
Line 65... | Line 65... | ||
65 | /** Insert item into hash table. |
65 | /** Insert item into hash table. |
66 | * |
66 | * |
67 | * @param h Hash table. |
67 | * @param h Hash table. |
68 | * @param hey Array of all keys necessary to compute hash index. |
68 | * @param hey Array of all keys necessary to compute hash index. |
69 | * @param item Item to be inserted into the hash table. |
69 | * @param item Item to be inserted into the hash table. |
70 | * |
- | |
71 | * @return true on success, false if the keys were already present in the hash table. |
- | |
72 | */ |
70 | */ |
73 | bool hash_table_insert(hash_table_t *h, __native key[], link_t *item) |
71 | void hash_table_insert(hash_table_t *h, __native key[], link_t *item) |
74 | { |
72 | { |
75 | index_t chain; |
73 | index_t chain; |
76 | 74 | ||
77 | ASSERT(item); |
75 | ASSERT(item); |
78 | ASSERT(h && h->op && h->op->hash && h->op->compare); |
76 | ASSERT(h && h->op && h->op->hash && h->op->compare); |
79 | 77 | ||
80 | chain = h->op->hash(key); |
78 | chain = h->op->hash(key); |
81 | ASSERT(chain < h->entries); |
79 | ASSERT(chain < h->entries); |
82 | 80 | ||
83 | if (hash_table_find(h, key)) { |
- | |
84 | /* |
- | |
85 | * The hash table is not redundant. |
- | |
86 | * Signal failure on return. |
- | |
87 | */ |
- | |
88 | return false; |
- | |
89 | } |
- | |
90 | - | ||
91 | list_append(item, &h->entry[chain]); |
81 | list_append(item, &h->entry[chain]); |
92 | return true; |
- | |
93 | } |
82 | } |
94 | 83 | ||
95 | /** Search hash table for an item matching keys. |
84 | /** Search hash table for an item matching keys. |
96 | * |
85 | * |
97 | * @param h Hash table. |
86 | * @param h Hash table. |