diff options
author | Igor Sysoev <igor@sysoev.ru> | 2007-12-07 23:19:41 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2007-12-07 23:19:41 +0300 |
commit | ac7586e9520861a78146afe387c981d6be9b4d7b (patch) | |
tree | a1ebc66ab56ed98505ed962109d1c19d0bfe7519 /src/core/ngx_crc32.h | |
parent | 27dd6a62bd76983e6bdc5c45e108aae816fac761 (diff) |
rename ngx_crc32_init() to ngx_crc32_table_init()
ngx_crc32_init(), ngx_crc32_update(), ngx_crc32_final()
Diffstat (limited to 'src/core/ngx_crc32.h')
-rw-r--r-- | src/core/ngx_crc32.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/core/ngx_crc32.h b/src/core/ngx_crc32.h index 7d5279d36..fe76156dc 100644 --- a/src/core/ngx_crc32.h +++ b/src/core/ngx_crc32.h @@ -49,7 +49,30 @@ ngx_crc32_long(u_char *p, size_t len) } -ngx_int_t ngx_crc32_init(void); +#define ngx_crc32_init(crc) \ + crc = 0xffffffff + + +static void +ngx_crc32_update(uint32_t *crc, u_char *p, size_t len) +{ + uint32_t c; + + c = *crc; + + while (len--) { + c = ngx_crc32_table256[(c ^ *p++) & 0xff] ^ (c >> 8); + } + + *crc = c; +} + + +#define ngx_crc32_final(crc) \ + crc ^= 0xffffffff + + +ngx_int_t ngx_crc32_table_init(void); #endif /* _NGX_CRC32_H_INCLUDED_ */ |