/src/dovecot/src/lib/crc32.c
Line | Count | Source |
1 | | /* Copyright (c) Dovecot authors, see top-level COPYING file */ |
2 | | |
3 | | #include "lib.h" |
4 | | #include "crc32.h" |
5 | | #include <zlib.h> |
6 | | |
7 | | uint32_t crc32_data(const void *data, size_t size) |
8 | 0 | { |
9 | 0 | return crc32_data_more(CRC32_INIT, data, size); |
10 | 0 | } |
11 | | |
12 | | uint32_t crc32_data_more(uint32_t crc, const void *data, size_t size) |
13 | 0 | { |
14 | 0 | const unsigned char *p = data; |
15 | 0 | uLong zcrc; |
16 | |
|
17 | 0 | if (crc == CRC32_INIT) { |
18 | | /* Start new CRC calculation. */ |
19 | 0 | zcrc = crc32_z(0L, Z_NULL, 0); |
20 | 0 | } else { |
21 | 0 | zcrc = crc; |
22 | 0 | } |
23 | |
|
24 | 0 | return (uint32_t)crc32_z(zcrc, p, size); |
25 | 0 | } |