From 1a1addcefdade540e0f355126e6a8f84a1d88596 Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Tue, 28 Feb 2017 23:59:30 +0100 Subject: [PATCH] move declarations at the block beginning (ANSI C) --- src/misc/crc32.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/misc/crc32.c b/src/misc/crc32.c index 8f9ca97..1099af2 100644 --- a/src/misc/crc32.c +++ b/src/misc/crc32.c @@ -149,9 +149,10 @@ void crc32_init(crc32_state *ctx) void crc32_update(crc32_state *ctx, const unsigned char *input, unsigned long length) { + ulong32 crc; LTC_ARGCHKVD(ctx != NULL); LTC_ARGCHKVD(input != NULL); - ulong32 crc = ctx->crc; + crc = ctx->crc; while (length--) crc = crc32_m_tab[CRC32_INDEX(crc) ^ *input++] ^ CRC32_SHIFTED(crc); @@ -161,14 +162,18 @@ void crc32_update(crc32_state *ctx, const unsigned char *input, unsigned long le void crc32_finish(crc32_state *ctx, void *hash, unsigned long size) { + unsigned char* h; + unsigned long i; + ulong32 crc; + LTC_ARGCHKVD(ctx != NULL); LTC_ARGCHKVD(hash != NULL); - unsigned char* h = hash; - unsigned long i; - - ulong32 crc = ctx->crc; + h = hash; + crc = ctx->crc; crc ^= _CRC32_NEGL; + + if (size > 4) size = 4; for (i = 0; i < size; i++) { h[i] = ((unsigned char*)&(crc))[i]; }