ulong **tempP = new ulong * [n / b + 1];
ulong *bitsInBSD = new ulong [n / b + 1];
ulong totalBits = 0;
- this->firstKeyA = new BlockArray(n/b + 1, Tools::CeilLog2(this->u));
+ // Number of nodes:
+ this->topCount = n%b ? n/b + 1: n/b;
+ this->firstKeyA = new BlockArray(topCount, Tools::CeilLog2(this->u));
for (ulong i = 0; i < n/b; i ++)
{
(*firstKeyA)[n/b] = firstKey;
}
- // Number of nodes:
- this->topCount = n%b ? n/b + 1: n/b;
-
// Catenate binary trees into one bitvector
this->P = new ulong[totalBits/W + 1];
+ for (ulong i = 0; i < totalBits/W + 1; ++i)
+ P[i] = 0;
this->bitsInP = totalBits;
ulong offset = 0;
for (ulong i = 0; i < this->topCount ; ++i)
// bits is the sum of keyBits, jumpBits, leftBits and rightBits
bits = keyBits + jumpBits + leftBits + rightBits;
ulong *output = new ulong[bits / W + 1];
+ for (ulong i = 0; i < bits/W+1; ++i)
+ output[i] = 0;
/**
* Write "output"
for (ulong offset = 0; offset < bitsInP/W+1; offset ++)
{
- if (std::fwrite(this->P+offset, sizeof(ulong), 1, file) != 1)
+ if (std::fwrite((this->P)+offset, sizeof(ulong), 1, file) != 1)
throw std::runtime_error("BSGAP::Save(): file write error (P).");
- }
+ }
if (std::fwrite(&(this->b), sizeof(unsigned), 1, file) != 1)
throw std::runtime_error("BSGAP::Save(): file write error (b).");