X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/4769a870917b98723690aa336d12d0656769528b..8b8f49b713d64065775fe538232f8639083601bd:/lunaix-os/includes/lunaix/ds/hashtable.h diff --git a/lunaix-os/includes/lunaix/ds/hashtable.h b/lunaix-os/includes/lunaix/ds/hashtable.h index 0e8c691..41ca36b 100644 --- a/lunaix-os/includes/lunaix/ds/hashtable.h +++ b/lunaix-os/includes/lunaix/ds/hashtable.h @@ -21,9 +21,9 @@ struct hbucket struct hlist_node* head; }; -#define __hashkey(table, hash) (hash % (sizeof(table) / sizeof(table[0]))) +#define __hashkey(table, hash) ((hash) % (sizeof(table) / sizeof(table[0]))) -#define DECLARE_HASHTABLE(name, bucket_num) struct hbucket name[bucket_num]; +#define DECLARE_HASHTABLE(name, bucket_num) struct hbucket name[(bucket_num)]; #define hashtable_bucket_foreach(bucket, pos, n, member) \ for (pos = list_entry((bucket)->head, typeof(*pos), member); \ @@ -38,7 +38,7 @@ struct hbucket #define hashtable_init(table) \ { \ - for (int i = 0; i < (sizeof(table) / sizeof(table[0])); i++) { \ + for (u32_t i = 0; i < (sizeof(table) / sizeof(table[0])); i++) { \ table[i].head = 0; \ } \ }