From 8a47e69de602ebcd2fb3e92d8861fcd8b7041ad3 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Wed, 2 Sep 2020 15:22:44 +0200 Subject: fix: signed/unsigned types --- hashtab.c | 8 ++++---- 1 file 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 hash_key(const unsigned char *str) { unsigned long hash = 5381; - int c; + unsigned int c; while ( (c = *str++) != '\0' ) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ @@ -33,7 +33,7 @@ hash_key(const unsigned char *str) void hash_init(struct hash_tab *ht) { - for ( int i = 0; i != NELEM(ht->table); ++i ) + for ( size_t i = 0; i != NELEM(ht->table); ++i ) ht->table[i] = NULL; } @@ -114,7 +114,7 @@ hash_apply(struct hash_tab *ht, void (*visit)(const char *key, T data, void *cl) { struct hash_item *item; - for ( int i = 0; i != NELEM(ht->table); ++i ) + for ( size_t i = 0; i != NELEM(ht->table); ++i ) for ( item = ht->table[i]; item; item = item->next ) visit(item->key, item->data, cl); } @@ -124,7 +124,7 @@ hash_free(struct hash_tab *ht) { struct hash_item *p, *next; - for ( int i = 0; i != NELEM(ht->table); ++i ) { + for ( size_t i = 0; i != NELEM(ht->table); ++i ) { for ( p = ht->table[i]; p; p = next ) { next = p->next; free(p->key); -- cgit v1.3