]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Compatibility fix for crc32()
authorMika Lindqvist <postmaster@raasu.org>
Mon, 25 Nov 2019 23:23:50 +0000 (01:23 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Tue, 26 Nov 2019 14:43:47 +0000 (15:43 +0100)
* Use "unsigned long" externally instead of "uint32_t" for crc
* Use "unsigned int" externally instead of "uint32_t" for len

Fixes #483

crc32.c
zlib.h

diff --git a/crc32.c b/crc32.c
index 4959ceac76471a56766a81e926badd5b5b077620..557067e4bed02166d9147d9c1134ed39420eea38 100644 (file)
--- a/crc32.c
+++ b/crc32.c
@@ -64,9 +64,15 @@ ZLIB_INTERNAL uint32_t crc32_generic(uint32_t crc, const unsigned char *buf, uin
     return crc ^ 0xffffffff;
 }
 
+#ifdef ZLIB_COMPAT
+unsigned long ZEXPORT PREFIX(crc32)(unsigned long crc, const unsigned char *buf, unsigned int len) {
+    return (unsigned long) PREFIX(crc32_z)((uint32_t) crc, buf, len);
+}
+#else
 uint32_t ZEXPORT PREFIX(crc32)(uint32_t crc, const unsigned char *buf, uint32_t len) {
     return PREFIX(crc32_z)(crc, buf, len);
 }
+#endif
 
 /*
    This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit
diff --git a/zlib.h b/zlib.h
index bd8c9733e2b4b7aac04f76f608504d2ef98c3141..5b2f32b3092c906286d6fc35a2ac9fa52371a039 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -1680,7 +1680,7 @@ ZEXTERN uint32_t ZEXPORT adler32_combine(uint32_t adler1, uint32_t adler2, z_off
    negative, the result has no meaning or utility.
 */
 
-ZEXTERN uint32_t ZEXPORT crc32(uint32_t crc, const unsigned char *buf, uint32_t len);
+ZEXTERN unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char *buf, unsigned int len);
 /*
      Update a running CRC-32 with the bytes buf[0..len-1] and return the
    updated CRC-32.  If buf is NULL, this function returns the required