summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-07-07 09:31:43 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-07-07 09:31:43 +0000
commit88be51e8cb18a704152b76b98d49a2bda6fff0a9 (patch)
treeb5458968564d5d0074519d4665d249029f0b892b
parent76d7c8ad887ac7b9dfdb495fe26ef8d4d8dfe370 (diff)
downloadhercules-88be51e8cb18a704152b76b98d49a2bda6fff0a9.tar.gz
hercules-88be51e8cb18a704152b76b98d49a2bda6fff0a9.tar.bz2
hercules-88be51e8cb18a704152b76b98d49a2bda6fff0a9.tar.xz
hercules-88be51e8cb18a704152b76b98d49a2bda6fff0a9.zip
* Replaced compress/uncompress inline code (encode_zip/decode_zip) with the respective zlib library calls while keeping 3rdparty calls inside common code (follow up to r14888, related r14808).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14891 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--src/common/grfio.c56
2 files changed, 4 insertions, 54 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 37acba5cf..c9ba2b510 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -1,5 +1,7 @@
Date Added
+2011/07/07
+ * Replaced compress/uncompress inline code (encode_zip/decode_zip) with the respective zlib library calls while keeping 3rdparty calls inside common code (follow up to r14888, related r14808). [Ai4rei]
2011/07/06
* Changed grfio.c include order and moved zlib include from the header to the source. [FlavioJS]
* Merged decode_zip/encode_zip from eapp's grfio to replace our direct use of zlib's uncompress/compress.
diff --git a/src/common/grfio.c b/src/common/grfio.c
index e31451af1..cb242fe5d 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -225,33 +225,7 @@ unsigned long grfio_crc32 (const unsigned char* buf, unsigned int len)
/// Grf data sub : zip decode
int decode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen)
{
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef*)source;
- stream.avail_in = (uInt)sourceLen;
- // Check for source > 64K on 16-bit machine:
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-
- stream.next_out = (Bytef*) dest;
- stream.avail_out = (uInt)*destLen;
- if ((unsigned long)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
-
- err = inflateInit(&stream);
- if (err != Z_OK) return err;
-
- err = inflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- inflateEnd(&stream);
- return err == Z_OK ? Z_BUF_ERROR : err;
- }
- *destLen = stream.total_out;
-
- err = inflateEnd(&stream);
- return err;
+ return uncompress(dest, destLen, source, sourceLen);
}
@@ -259,33 +233,7 @@ int decode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char*
/// Grf data sub : zip encode
int encode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen)
{
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef*)source;
- stream.avail_in = (uInt)sourceLen;
- // Check for source > 64K on 16-bit machine:
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-
- stream.next_out = (Bytef*) dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
-
- err = deflateInit(&stream,Z_DEFAULT_COMPRESSION);
- if (err != Z_OK) return err;
-
- err = deflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- deflateEnd(&stream);
- return err == Z_OK ? Z_BUF_ERROR : err;
- }
- *destLen = stream.total_out;
-
- err = deflateEnd(&stream);
- return err;
+ return compress(dest, destLen, source, sourceLen);
}