From 9811b53dd9e8f67015c7199fff12b5bfc6965330 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Fri, 9 Sep 2011 23:24:24 -0700 Subject: zlib 1.2.2.1 --- adler32.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'adler32.c') diff --git a/adler32.c b/adler32.c index 624a169..94f1021 100644 --- a/adler32.c +++ b/adler32.c @@ -1,5 +1,5 @@ /* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2003 Mark Adler + * Copyright (C) 1995-2004 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -72,3 +72,25 @@ uLong ZEXPORT adler32(adler, buf, len) } return (s2 << 16) | s1; } + +/* ========================================================================= */ +uLong ZEXPORT adler32_combine(adler1, adler2, len2) + uLong adler1; + uLong adler2; + uLong len2; +{ + unsigned long s1; + unsigned long s2; + + len2 %= BASE; + s1 = adler1 & 0xffff; + s2 = len2 * s1; + MOD(s2); + s1 += (adler2 & 0xffff) + BASE - 1; + s2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - len2; + if (s1 > BASE) s1 -= BASE; + if (s1 > BASE) s1 -= BASE; + if (s2 > (BASE << 1)) s2 -= (BASE << 1); + if (s2 > BASE) s2 -= BASE; + return (s2 << 16) | s1; +} -- cgit v1.2.3-55-g6feb