PBitArray::GetLength() returns length in bits
Brought to you by:
csoutheren,
rjongbloed
PTLib 2.18.8 release bundle.
When calling GetLength() on a PBitArray object, a value in bits is returned, while the documentation says: "Retrun the length in bytes for the array".
This method is derived from PAbstractArray::GetLength() and is defined as:
return elementSize*GetSize();
elementSize is 1 and virtual GetSize() returns bit count for PBitArray (as expected). So we get GetLength() in bits, not in bytes.
Strictly speaking, elementSize should be 1/8 (bytes) for PBitArray, but fractions can't be used here. And this finally produces incorrect values returned by GetLength().
Suggested solution:
Override GetLength() for PBitArray class as:
PINDEX PBitArray::GetLength() const
{
return PBYTEArray::GetSize();
}