I need to create a Memory Block consisting of various type data.
More specifically, I need to have a memory block with the following structure:
At the begining, it holds the raw contents of a two or more uint32 vars, indicating the length of the consecutive data.
The consecutive data are plain Strings with the appropriate size, as indicated by uint32 vars.
When I try to copy these data using the Memory Block::copy From() function, what I take is a completely unexpected result.
size_t S1 = Keys.getSize(); // it returns the size of memory block
if (Out.openedOk())
{
Out.setPosition(0);
return Out.write(&Keys, Keys.getSize());
}
}
I don't understand what am I doing wrong. The following piece of code has the following unexpected results :
- the keys.getSize() returns a value less than the actual size of its content (i.e. the actual size of data is 253 chars, the .getSize() returns a value of 203 ( chars).
- As a result, the data written to Out file, has a length of 203 chars instead of its actual size.
- Even though the MemoryBlock's data seem to be ok, after turned them to UTF8 format , unfortunatelly, when I read back the data, the following jassert (CharPointer_UTF8::isValidString (buffer, bufferSizeBytes)), interrupts the proccess of reading..