diff options
| -rw-r--r-- | hashtab.c | 8 |
1 files changed, 4 insertions, 4 deletions
| @@ -22,7 +22,7 @@ static unsigned long | |||
| 22 | hash_key(const unsigned char *str) | 22 | hash_key(const unsigned char *str) |
| 23 | { | 23 | { |
| 24 | unsigned long hash = 5381; | 24 | unsigned long hash = 5381; |
| 25 | int c; | 25 | unsigned int c; |
| 26 | 26 | ||
| 27 | while ( (c = *str++) != '\0' ) | 27 | while ( (c = *str++) != '\0' ) |
| 28 | hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ | 28 | hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ |
| @@ -33,7 +33,7 @@ hash_key(const unsigned char *str) | |||
| 33 | void | 33 | void |
| 34 | hash_init(struct hash_tab *ht) | 34 | hash_init(struct hash_tab *ht) |
| 35 | { | 35 | { |
| 36 | for ( int i = 0; i != NELEM(ht->table); ++i ) | 36 | for ( size_t i = 0; i != NELEM(ht->table); ++i ) |
| 37 | ht->table[i] = NULL; | 37 | ht->table[i] = NULL; |
| 38 | } | 38 | } |
| 39 | 39 | ||
| @@ -114,7 +114,7 @@ hash_apply(struct hash_tab *ht, void (*visit)(const char *key, T data, void *cl) | |||
| 114 | { | 114 | { |
| 115 | struct hash_item *item; | 115 | struct hash_item *item; |
| 116 | 116 | ||
| 117 | for ( int i = 0; i != NELEM(ht->table); ++i ) | 117 | for ( size_t i = 0; i != NELEM(ht->table); ++i ) |
| 118 | for ( item = ht->table[i]; item; item = item->next ) | 118 | for ( item = ht->table[i]; item; item = item->next ) |
| 119 | visit(item->key, item->data, cl); | 119 | visit(item->key, item->data, cl); |
| 120 | } | 120 | } |
| @@ -124,7 +124,7 @@ hash_free(struct hash_tab *ht) | |||
| 124 | { | 124 | { |
| 125 | struct hash_item *p, *next; | 125 | struct hash_item *p, *next; |
| 126 | 126 | ||
| 127 | for ( int i = 0; i != NELEM(ht->table); ++i ) { | 127 | for ( size_t i = 0; i != NELEM(ht->table); ++i ) { |
| 128 | for ( p = ht->table[i]; p; p = next ) { | 128 | for ( p = ht->table[i]; p; p = next ) { |
| 129 | next = p->next; | 129 | next = p->next; |
| 130 | free(p->key); | 130 | free(p->key); |
