Rev 1757 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1757 | Rev 1780 | ||
---|---|---|---|
Line 62... | Line 62... | ||
62 | 62 | ||
63 | h->entry = malloc(m * sizeof(link_t), 0); |
63 | h->entry = malloc(m * sizeof(link_t), 0); |
64 | if (!h->entry) { |
64 | if (!h->entry) { |
65 | panic("cannot allocate memory for hash table\n"); |
65 | panic("cannot allocate memory for hash table\n"); |
66 | } |
66 | } |
67 | memsetb((__address) h->entry, m * sizeof(link_t), 0); |
67 | memsetb((uintptr_t) h->entry, m * sizeof(link_t), 0); |
68 | 68 | ||
69 | for (i = 0; i < m; i++) |
69 | for (i = 0; i < m; i++) |
70 | list_initialize(&h->entry[i]); |
70 | list_initialize(&h->entry[i]); |
71 | 71 | ||
72 | h->entries = m; |
72 | h->entries = m; |
Line 78... | Line 78... | ||
78 | * |
78 | * |
79 | * @param h Hash table. |
79 | * @param h Hash table. |
80 | * @param key Array of all keys necessary to compute hash index. |
80 | * @param key Array of all keys necessary to compute hash index. |
81 | * @param item Item to be inserted into the hash table. |
81 | * @param item Item to be inserted into the hash table. |
82 | */ |
82 | */ |
83 | void hash_table_insert(hash_table_t *h, __native key[], link_t *item) |
83 | void hash_table_insert(hash_table_t *h, unative_t key[], link_t *item) |
84 | { |
84 | { |
85 | index_t chain; |
85 | index_t chain; |
86 | 86 | ||
87 | ASSERT(item); |
87 | ASSERT(item); |
88 | ASSERT(h && h->op && h->op->hash && h->op->compare); |
88 | ASSERT(h && h->op && h->op->hash && h->op->compare); |
Line 98... | Line 98... | ||
98 | * @param h Hash table. |
98 | * @param h Hash table. |
99 | * @param key Array of all keys needed to compute hash index. |
99 | * @param key Array of all keys needed to compute hash index. |
100 | * |
100 | * |
101 | * @return Matching item on success, NULL if there is no such item. |
101 | * @return Matching item on success, NULL if there is no such item. |
102 | */ |
102 | */ |
103 | link_t *hash_table_find(hash_table_t *h, __native key[]) |
103 | link_t *hash_table_find(hash_table_t *h, unative_t key[]) |
104 | { |
104 | { |
105 | link_t *cur; |
105 | link_t *cur; |
106 | index_t chain; |
106 | index_t chain; |
107 | 107 | ||
108 | ASSERT(h && h->op && h->op->hash && h->op->compare); |
108 | ASSERT(h && h->op && h->op->hash && h->op->compare); |
Line 128... | Line 128... | ||
128 | * |
128 | * |
129 | * @param h Hash table. |
129 | * @param h Hash table. |
130 | * @param key Array of keys that will be compared against items of the hash table. |
130 | * @param key Array of keys that will be compared against items of the hash table. |
131 | * @param keys Number of keys in the key array. |
131 | * @param keys Number of keys in the key array. |
132 | */ |
132 | */ |
133 | void hash_table_remove(hash_table_t *h, __native key[], count_t keys) |
133 | void hash_table_remove(hash_table_t *h, unative_t key[], count_t keys) |
134 | { |
134 | { |
135 | index_t chain; |
135 | index_t chain; |
136 | link_t *cur; |
136 | link_t *cur; |
137 | 137 | ||
138 | ASSERT(h && h->op && h->op->hash && h->op->compare && h->op->remove_callback); |
138 | ASSERT(h && h->op && h->op->hash && h->op->compare && h->op->remove_callback); |