I've been trying to deflate and inflate a string, and this works:
char text[600] = "Testing deflating and inflating";
char out[600];
uLong ucompSize = strlen(text) + 1;
uLong compSize = compressBound(ucompSize);
// Deflate
compress((Bytef *)out, &compSize, (Bytef *)text, ucompSize);
But my problem is that the needed space for the out (and the string itself) can vary a lot, I tried using std::string 's but it doesn't work, I get the following error:
_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
_CrtIsValidHeapPointer(pUserData)
My current code with std::string is this one
char text[600] = "Testing deflating and inflating";
std::string out;
uLong ucompSize = strlen(text) + 1;
uLong compSize = compressBound(ucompSize);
// Deflate
compress((Bytef *)out.data(), &compSize, (Bytef *)text, ucompSize);
I've been searching in Google but I can't find a solution, I just need to inflate and deflate big strings. I'm not good in C++ (I always work with Ruby, where I can do this just with Zlib::Deflate.deflate(@string))
Can anyone help/teach me? Thanks you