rculfhash: Cast to struct rcu_level * instead of void * (cleanup)
[urcu.git] / rculfhash.c
index 675ef382311beafcbb8d62ad284b2032d6db79aa..ca63457b7237288a8b7816efef9bed1aa9c2c3a3 100644 (file)
@@ -738,17 +738,21 @@ struct _cds_lfht_node *lookup_bucket(struct cds_lfht *ht, unsigned long size,
 
        assert(size > 0);
        index = hash & (size - 1);
+
+       if (index < ht->min_alloc_size) {
+               dbg_printf("lookup hash %lu index %lu order 0 aridx 0\n",
+                          hash, index);
+               return &ht->t.tbl[0]->nodes[index];
+       }
        /*
         * equivalent to get_count_order_ulong(index + 1), but optimizes
         * away the non-existing 0 special-case for
         * get_count_order_ulong.
         */
        order = fls_ulong(index);
-
        dbg_printf("lookup hash %lu index %lu order %lu aridx %lu\n",
-                  hash, index, order, index & (!order ? 0 : ((1UL << (order - 1)) - 1)));
-
-       return &ht->t.tbl[order]->nodes[index & (!order ? 0 : ((1UL << (order - 1)) - 1))];
+                  hash, index, order, index & ((1UL << (order - 1)) - 1));
+       return &ht->t.tbl[order]->nodes[index & ((1UL << (order - 1)) - 1)];
 }
 
 /*
@@ -1280,7 +1284,7 @@ void cds_lfht_create_dummy(struct cds_lfht *ht, unsigned long size)
        for (order = 1; order < get_count_order_ulong(size) + 1; order++) {
                len = 1UL << (order - 1);
                if (order <= ht->min_alloc_order) {
-                       ht->t.tbl[order] = (void *)(ht->t.tbl[0]->nodes + len);
+                       ht->t.tbl[order] = (struct rcu_level *) (ht->t.tbl[0]->nodes + len);
                } else {
                        ht->t.tbl[order] = calloc(1, len * sizeof(struct _cds_lfht_node));
                        assert(ht->t.tbl[order]);
This page took 0.03412 seconds and 4 git commands to generate.