Tom Gundersen
cdf6f5ae04
basic: bitmap - complete fix for bitshift overflow
...
The bug found by David existed in several places, fix them all. Also
extend the tests to cover these cases.
2015-07-17 18:59:16 +02:00
David Herrmann
a933570dea
bitmap: avoid 32bit integer overflow in shift
...
We really must use 64bit integers to calculate long-long shifts.
Otherwise, we will never get higher masks than 2^31.
2015-07-17 12:19:06 +02:00
David Herrmann
22cedfe15f
bitmap: allow bitmap_iterate() on NULL bitmap
...
Make sure we properly treat NULL bitmaps as empty. Right now, we don't
(which really looks like a typo).
2015-07-17 12:18:13 +02:00
Tom Gundersen
cb57dd4159
bitmap: use external iterator
...
Reuse the Iterator object from hashmap.h and expose a similar API.
This allows us to do
{
Iterator i;
unsigned n;
BITMAP_FOREACH(n, b, i) {
Iterator j;
unsigned m;
BITMAP_FOREACH(m, b, j) {
...
}
}
}
without getting confused. Requested by David.
2015-07-16 14:11:12 +02:00
Tom Gundersen
5ffa42cb80
basic: add a Bitmap implementation
...
For when a Hashmap is overkill.
2015-07-14 21:53:10 +02:00