diff options
author | David Robillard <d@drobilla.net> | 2012-08-10 23:06:54 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-08-10 23:06:54 +0000 |
commit | 73874347374b6130dd55eb851ce7a144795b53ba (patch) | |
tree | 10c2ece9b4d983db1f3a720e3bac49be087c9b5d /zix | |
parent | 0bb59462ed60f87eb18effdd06e74a750e274ca8 (diff) | |
download | zix-73874347374b6130dd55eb851ce7a144795b53ba.tar.gz zix-73874347374b6130dd55eb851ce7a144795b53ba.tar.bz2 zix-73874347374b6130dd55eb851ce7a144795b53ba.zip |
Fix void pointer arithmetic.
git-svn-id: http://svn.drobilla.net/zix/trunk@77 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
Diffstat (limited to 'zix')
-rw-r--r-- | zix/digest.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/zix/digest.c b/zix/digest.c index 4e8e974..04f48f0 100644 --- a/zix/digest.c +++ b/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; |