Rev 822 | Rev 1154 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 822 | Rev 902 | ||
|---|---|---|---|
| Line 45... | Line 45... | ||
| 45 | * @param max_keys Maximal number of keys needed to identify an item. |
45 | * @param max_keys Maximal number of keys needed to identify an item. |
| 46 | * @param op Hash table operations structure. |
46 | * @param op Hash table operations structure. |
| 47 | */ |
47 | */ |
| 48 | void hash_table_create(hash_table_t *h, count_t m, count_t max_keys, hash_table_operations_t *op) |
48 | void hash_table_create(hash_table_t *h, count_t m, count_t max_keys, hash_table_operations_t *op) |
| 49 | { |
49 | { |
| - | 50 | int i; |
|
| - | 51 | ||
| 50 | ASSERT(h); |
52 | ASSERT(h); |
| 51 | ASSERT(op && op->hash && op->compare); |
53 | ASSERT(op && op->hash && op->compare); |
| 52 | ASSERT(max_keys > 0); |
54 | ASSERT(max_keys > 0); |
| 53 | 55 | ||
| 54 | h->entry = malloc(m * sizeof(link_t *), 0); |
56 | h->entry = malloc(m * sizeof(link_t *), 0); |
| 55 | if (!h->entry) { |
57 | if (!h->entry) { |
| 56 | panic("cannot allocate memory for hash table\n"); |
58 | panic("cannot allocate memory for hash table\n"); |
| 57 | } |
59 | } |
| 58 | memsetb((__address) h->entry, m * sizeof(link_t *), 0); |
60 | memsetb((__address) h->entry, m * sizeof(link_t *), 0); |
| 59 | 61 | ||
| - | 62 | for (i = 0; i < m; i++) |
|
| - | 63 | list_initialize(&h->entry[i]); |
|
| - | 64 | ||
| 60 | h->entries = m; |
65 | h->entries = m; |
| 61 | h->max_keys = max_keys; |
66 | h->max_keys = max_keys; |
| 62 | h->op = op; |
67 | h->op = op; |
| 63 | } |
68 | } |
| 64 | 69 | ||