aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2020-09-02 15:22:44 +0200
committerThomas Schmucker <ts@its1.de>2020-09-02 15:22:44 +0200
commit8a47e69de602ebcd2fb3e92d8861fcd8b7041ad3 (patch)
treee347e87f4245b4b2eceb7c97ff4320e4969c021a
parent7c07ce626aec7e88d74b5d26a6329334a2feb946 (diff)
downloaddata-structures-8a47e69de602ebcd2fb3e92d8861fcd8b7041ad3.tar.gz
data-structures-8a47e69de602ebcd2fb3e92d8861fcd8b7041ad3.tar.bz2
data-structures-8a47e69de602ebcd2fb3e92d8861fcd8b7041ad3.zip
fix: signed/unsigned types
-rw-r--r--hashtab.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/hashtab.c b/hashtab.c
index e53da51..ea097ad 100644
--- a/hashtab.c
+++ b/hashtab.c
@@ -22,7 +22,7 @@ static unsigned long
22hash_key(const unsigned char *str) 22hash_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)
33void 33void
34hash_init(struct hash_tab *ht) 34hash_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);