Skip to content

Commit

Permalink
Compatibility fix for crc32()
Browse files Browse the repository at this point in the history
* Use "unsigned long" externally instead of "uint32_t" for crc
* Use "unsigned int" externally instead of "uint32_t" for len

Fixes #483
  • Loading branch information
mtl1979 authored and Dead2 committed Nov 26, 2019
1 parent edad2ab commit 3ea7473
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion zlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3ea7473

Please sign in to comment.