From c5d76179a5cccae5b75dd1b1f2c4037b362a9a35 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 25 Aug 2018 18:04:55 -0400 Subject: [PATCH] improve interaction of slot rand with slot mask --- malloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/malloc.c b/malloc.c index b6d9866..603d476 100644 --- a/malloc.c +++ b/malloc.c @@ -257,7 +257,7 @@ static size_t get_free_slot(struct random_state *rng, size_t slots, struct slab_ } // randomize start location for linear search (uniform random choice is too slow) - uint64_t random_split = ~0UL >> get_random_size_uniform(rng, slots); + uint64_t random_split = ~(~0UL << get_random_size_uniform(rng, slots)); size_t slot = ffzl(masked | random_split); if (slot) {