Mercurial > hg > nginx
diff src/core/ngx_crc32.h @ 1694:8c696afe46b3
rename ngx_crc32_init() to ngx_crc32_table_init()
ngx_crc32_init(), ngx_crc32_update(), ngx_crc32_final()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 07 Dec 2007 20:19:41 +0000 |
parents | 45df22906c12 |
children | d6afb8723155 |
line wrap: on
line diff
--- a/src/core/ngx_crc32.h Fri Dec 07 19:57:13 2007 +0000 +++ b/src/core/ngx_crc32.h Fri Dec 07 20:19:41 2007 +0000 @@ -49,7 +49,30 @@ } -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_ */