Make GWBITMASK fixed size

Originally GWBITMASK was capable of extending itself dynamically,
a functionality that in practice was never used, and that, in fact,
was broken.

As GWBITMASK is used for a single purpose inside MaxScale, its size
is now fixed at 256 bits, which is sufficient for 256 threads. Its
fixed size removes a few potential error situations that now then
do not need to be dealt with. And in principle is also more
performant.

In a separate change, bitmask_free will be renamed to bitmask_finish,
as contrary to free-functions in general, the function does not free
the argument, but only its data. The implementation will be empty,
but the function left in place for symmetry reasons (alloc/free,
init/finish).
This commit is contained in:
Johan Wikman
2016-08-15 22:59:39 +03:00
parent 1f10b6337e
commit ed96e2c54a
3 changed files with 62 additions and 132 deletions

View File

@ -38,10 +38,9 @@
#include <skygw_debug.h>
/**
* test1 Allocate table of users and mess around with it
* test1 Create a bitmap and mess around with it
*
*/
*/
static int
test1()
{
@ -52,8 +51,7 @@ test1()
ss_dfprintf(stderr,
"testgwbitmask : Initialise a bitmask");
bitmask_init(&bitmask);
ss_info_dassert(BIT_LENGTH_INITIAL == bitmask.length, "Length should be initial length.");
for (i = 0; i < BIT_LENGTH_INITIAL; i++)
for (i = 0; i < MXS_BITMASK_LENGTH; i++)
{
ss_info_dassert(0 == bitmask_isset(&bitmask, i), "All bits should initially be zero");
}
@ -64,14 +62,11 @@ test1()
ss_info_dassert(0 != bitmask_isset(&another, 17), "Test bit should be set");
ss_dfprintf(stderr, "\t..done\nClear the arbitrary bit.");
bitmask_clear(&bitmask, 17);
ss_info_dassert(0 == bitmask_isset(&bitmask, 17), "Test bit should be clear");
ss_info_dassert(0 != bitmask_isallclear(&bitmask), "Should be all clear");
// Testing the allocation mechanism, for use with valgrind.
bitmask_set(&bitmask, BIT_LENGTH_INC + 1);
bitmask_set(&bitmask, 2 * BIT_LENGTH_INC + 1);
ss_info_dassert(0 == bitmask_isset(&bitmask, 17), "Test bit should be clear");
ss_dfprintf(stderr, "\t..done\nFree the bitmask.");
bitmask_free(&bitmask);
ss_info_dassert(0 == bitmask.length, "Length should be zero after bit mask freed.");
ss_dfprintf(stderr, "\t..done\n");
return 0;