07-12-2014, 10:35 PM
(This post was last modified: 07-12-2014, 11:15 PM by daniel0916.)
And how can i do it then?
Random Chitchat 2012-2016
|
07-12-2014, 10:35 PM
(This post was last modified: 07-12-2014, 11:15 PM by daniel0916.)
And how can i do it then?
07-13-2014, 12:39 AM
Fix this line
Code: int UncompressedMaxSize = DataLength - (DataLength << 12) - (DataLength << 14) - (DataLength << 25) - 16;
07-13-2014, 01:27 AM
(This post was last modified: 07-13-2014, 01:28 AM by daniel0916.)
(07-13-2014, 12:39 AM)FakeTruth Wrote: Fix this line It's the opposite of the compress code. I use now 1000000 for testing. Code: char Output [1000000];
07-13-2014, 06:12 AM
(07-13-2014, 01:27 AM)daniel0916 Wrote:(07-13-2014, 12:39 AM)FakeTruth Wrote: Fix this line I don't know. I don't know what ChunkData is, or what DataLength is, or what it holds. You should definitely focus on this line though: Code: int UncompressedMaxSize = DataLength - (DataLength << 12) - (DataLength << 14) - (DataLength << 25) - 16; I'm telling you, check the resulting value of that calculation, it's probably not what you expect. I expect a negative number. Do you know what << means? Thanks given by: daniel0916
(07-13-2014, 01:27 AM)daniel0916 Wrote: I use now 1000000 for testing. 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 Thanks given by: daniel0916
07-13-2014, 05:46 PM
Xoft, is that not a pointer to the length of the buffer, not the buffer itself?
07-13-2014, 07:47 PM
07-13-2014, 09:46 PM
Slightly edited to make it more comprehensible
07-13-2014, 10:06 PM
(This post was last modified: 07-13-2014, 10:09 PM by daniel0916.)
Okay, thanks.
Code: char Output [1000000]; Is this code right? Because the client disconnects because it's too big. I think i need to define on the Write method the writed size not the full size or?
07-13-2014, 10:11 PM
The client expects compressed data, so it will disconnect if you write uncompressed data to it.
|
« Next Oldest | Next Newest »
|