mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-21 23:08:07 +00:00
poggers test commit
This commit is contained in:
@@ -8,6 +8,34 @@ namespace ZCompression {
|
||||
return (nLenSrc + 6 + (n16kBlocks * 5));
|
||||
}
|
||||
|
||||
int32_t GZipCompress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst) {
|
||||
z_stream stream;
|
||||
stream.next_in = (Bytef*)abSrc;
|
||||
stream.avail_in = nLenSrc;
|
||||
stream.next_out = (Bytef*)abDst;
|
||||
stream.avail_out = nLenDst;
|
||||
stream.zalloc = Z_NULL;
|
||||
stream.zfree = Z_NULL;
|
||||
stream.opaque = Z_NULL;
|
||||
|
||||
int32_t nErr, nRet = -1;
|
||||
nErr = deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY);
|
||||
if (nErr == Z_OK) {
|
||||
nErr = deflate(&stream, Z_FINISH);
|
||||
if (nErr == Z_STREAM_END) {
|
||||
nRet = stream.total_out;
|
||||
} else {
|
||||
deflateEnd(&stream);
|
||||
return nErr;
|
||||
}
|
||||
} else {
|
||||
return nErr;
|
||||
}
|
||||
|
||||
nErr = deflateEnd(&stream);
|
||||
return (nErr == Z_OK) ? nRet : nErr;
|
||||
}
|
||||
|
||||
int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst) {
|
||||
z_stream zInfo = { 0 };
|
||||
zInfo.total_in = zInfo.avail_in = nLenSrc;
|
||||
|
@@ -5,6 +5,7 @@
|
||||
namespace ZCompression {
|
||||
int32_t GetMaxCompressedLength(int32_t nLenSrc);
|
||||
|
||||
int32_t GZipCompress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst);
|
||||
int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst);
|
||||
|
||||
int32_t Decompress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst, int32_t& nErr);
|
||||
|
Reference in New Issue
Block a user