Skip to content

Commit b9ae6f0

Browse files
committed
Add crc32_z() and adler32_z() functions with size_t lengths.
1 parent 61b91f2 commit b9ae6f0

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

adler32.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
6060
#endif
6161

6262
/* ========================================================================= */
63-
uLong ZEXPORT adler32(adler, buf, len)
63+
uLong ZEXPORT adler32_z(adler, buf, len)
6464
uLong adler;
6565
const Bytef *buf;
66-
uInt len;
66+
z_size_t len;
6767
{
6868
unsigned long sum2;
6969
unsigned n;
@@ -130,6 +130,15 @@ uLong ZEXPORT adler32(adler, buf, len)
130130
return adler | (sum2 << 16);
131131
}
132132

133+
/* ========================================================================= */
134+
uLong ZEXPORT adler32(adler, buf, len)
135+
uLong adler;
136+
const Bytef *buf;
137+
uInt len;
138+
{
139+
return adler32_z(adler, buf, len);
140+
}
141+
133142
/* ========================================================================= */
134143
local uLong adler32_combine_(adler1, adler2, len2)
135144
uLong adler1;

crc32.c

+15-6
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
#endif
3737
#ifdef BYFOUR
3838
local unsigned long crc32_little OF((unsigned long,
39-
const unsigned char FAR *, unsigned));
39+
const unsigned char FAR *, z_size_t));
4040
local unsigned long crc32_big OF((unsigned long,
41-
const unsigned char FAR *, unsigned));
41+
const unsigned char FAR *, z_size_t));
4242
# define TBLS 8
4343
#else
4444
# define TBLS 1
@@ -199,10 +199,10 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
199199
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
200200

201201
/* ========================================================================= */
202-
unsigned long ZEXPORT crc32(crc, buf, len)
202+
unsigned long ZEXPORT crc32_z(crc, buf, len)
203203
unsigned long crc;
204204
const unsigned char FAR *buf;
205-
uInt len;
205+
z_size_t len;
206206
{
207207
if (buf == Z_NULL) return 0UL;
208208

@@ -233,6 +233,15 @@ unsigned long ZEXPORT crc32(crc, buf, len)
233233
return crc ^ 0xffffffffUL;
234234
}
235235

236+
/* ========================================================================= */
237+
unsigned long ZEXPORT crc32(crc, buf, len)
238+
unsigned long crc;
239+
const unsigned char FAR *buf;
240+
uInt len;
241+
{
242+
return crc32_z(crc, buf, len);
243+
}
244+
236245
#ifdef BYFOUR
237246

238247
/*
@@ -257,7 +266,7 @@ unsigned long ZEXPORT crc32(crc, buf, len)
257266
local unsigned long crc32_little(crc, buf, len)
258267
unsigned long crc;
259268
const unsigned char FAR *buf;
260-
unsigned len;
269+
z_size_t len;
261270
{
262271
register z_crc_t c;
263272
register const z_crc_t FAR *buf4;
@@ -297,7 +306,7 @@ local unsigned long crc32_little(crc, buf, len)
297306
local unsigned long crc32_big(crc, buf, len)
298307
unsigned long crc;
299308
const unsigned char FAR *buf;
300-
unsigned len;
309+
z_size_t len;
301310
{
302311
register z_crc_t c;
303312
register const z_crc_t FAR *buf4;

zlib.h

+12
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,12 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
17021702
if (adler != original_adler) error();
17031703
*/
17041704

1705+
ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf,
1706+
z_size_t len));
1707+
/*
1708+
Same as adler32(), but with a size_t length.
1709+
*/
1710+
17051711
/*
17061712
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
17071713
z_off_t len2));
@@ -1731,6 +1737,12 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
17311737
if (crc != original_crc) error();
17321738
*/
17331739

1740+
ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
1741+
z_size_t len));
1742+
/*
1743+
Same as crc32(), but with a size_t length.
1744+
*/
1745+
17341746
/*
17351747
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
17361748

0 commit comments

Comments
 (0)