(07-13-2014, 01:27 AM)daniel0916 Wrote: I use now 1000000 for testing.
But then the uncompress crashes. Shouldn't i use c_str() or so?Code:char Output [1000000];
int success = uncompress((Bytef *)Output, (uLongf *)1000000, (const Bytef *)ChunkData.c_str(), (uLong)DataLength);
Of course it crashes. The second parameter is all wrong. The function expects a pointer to memory where the buffer's length is stored, and it writes to that memory the actual number of bytes written. You're forcing a number down its throat instead of a pointer, so it tries to access memory at address 1000000. Most likely that address is not available for the program, so it crashes; but even if it didn't crash, it wouldn't work well for you.
You need to do this:
char Output [1000000]; uLongf BufferSize = sizeof(Output); int success = uncompress((Bytef *)Output, &BufferSize, (const Bytef *)ChunkData.data(), (uLong)DataLength); // BufferSize now contains the number of bytes actually uncompressed