Deal with wrap around in statistics.

This commit is contained in:
Matthew Parkinson
2019-08-13 13:43:20 +01:00
parent bef2fb94d8
commit dd3feb948c

View File

@@ -141,7 +141,9 @@ namespace snmalloc
UNUSED(size);
#ifdef USE_SNMALLOC_STATS
bucketed_requests[bits::to_exp_mant<BUCKETS_BITS>(size)]++;
auto index = (size == 0) ? 0 : bits::to_exp_mant<BUCKETS_BITS>(size);
assert(index < TOTAL_BUCKETS);
bucketed_requests[index]++;
#endif
}