rculfhash: Check that init size is power of 2
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 3 Sep 2011 15:42:30 +0000 (11:42 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 3 Sep 2011 15:42:30 +0000 (11:42 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
rculfhash.c

index 9aeb3e76598071c0b450a4287c2fe8c615bc9a29..1720afb61669e971968fc2cfcd994db3e6b7b8be 100644 (file)
@@ -621,6 +621,9 @@ struct cds_lfht *cds_lfht_new(cds_lfht_hash_fct hash_fct,
        struct cds_lfht *ht;
        unsigned long order;
 
+       /* init_size must be power of two */
+       if (init_size & (init_size - 1))
+               return NULL;
        ht = calloc(1, sizeof(struct cds_lfht));
        ht->hash_fct = hash_fct;
        ht->compare_fct = compare_fct;
This page took 0.026203 seconds and 4 git commands to generate.