From 97baef1fd8a6c8953c17419d38138e0835005627 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 10 Aug 2012 23:07:02 +0000 Subject: Fix void pointer arithmetic. git-svn-id: http://svn.drobilla.net/sord/trunk@252 3d64ff67-21c5-427c-a301-fe4f08042e5a --- src/zix/digest.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/zix/digest.c b/src/zix/digest.c index 4e8e974..04f48f0 100644 --- a/src/zix/digest.c +++ b/src/zix/digest.c @@ -31,25 +31,26 @@ zix_digest_start(void) } ZIX_API uint32_t -zix_digest_add(uint32_t hash, const void* buf, const size_t len) +zix_digest_add(uint32_t hash, const void* const buf, const size_t len) { + const uint8_t* str = (const uint8_t*)buf; #ifdef __SSE4_2__ // SSE 4.2 CRC32 for (size_t i = 0; i < (len / sizeof(uint32_t)); ++i) { - hash = _mm_crc32_u32(hash, *(uint32_t*)buf); - buf += sizeof(uint32_t); + hash = _mm_crc32_u32(hash, *(uint32_t*)str); + str += sizeof(uint32_t); } if (len & sizeof(uint16_t)) { - hash = _mm_crc32_u16(hash, *(uint16_t*)buf); - buf += sizeof(uint16_t); + hash = _mm_crc32_u16(hash, *(uint16_t*)str); + str += sizeof(uint16_t); } if (len & sizeof(uint8_t)) { - hash = _mm_crc32_u8(hash, *(uint8_t*)buf); + hash = _mm_crc32_u8(hash, *(uint8_t*)str); } #else // Classic DJB hash for (size_t i = 0; i < len; ++i) { - hash = (hash << 5) + hash + ((const uint8_t*)buf)[i]; + hash = (hash << 5) + hash + str[i]; } #endif return hash; -- cgit v1.2.1