BF: change byteswap from 8 to 2
the byteSwap
method loops over nElements
of a specified elementLength
void byteSwap(const size_t elementLength, void* vBuffer,const unsigned long nElements)
{
//cerr << "Low level byte swap: " << elementLength << " " << vBuffer << " " << nElements << endl;
char *buffer(static_cast<char *>(vBuffer));
for ( unsigned long current = 0; current < nElements; current ++ ) {
reverse(buffer,buffer+elementLength);
buffer+=elementLength;
}
}
The old line byteSwap(sizeof(iBuffer[0]), iBuffer, 8);
was being told to byte swap 8 elements each of size 4 (int32_t
). But it should be byteSwap(sizeof(iBuffer[0]), iBuffer, 2);
since iBuffer
only has 2 elements each with size 4.