summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-08-10 23:07:02 +0000
committerDavid Robillard <d@drobilla.net>2012-08-10 23:07:02 +0000
commit97baef1fd8a6c8953c17419d38138e0835005627 (patch)
tree5fb7e9a026311b4d74298bc8a0bb778fe9aa1ca9
parent1144d52d67083cb2f2709f2f43c3b7c259c37d9c (diff)
downloadsord-97baef1fd8a6c8953c17419d38138e0835005627.tar.gz
sord-97baef1fd8a6c8953c17419d38138e0835005627.tar.bz2
sord-97baef1fd8a6c8953c17419d38138e0835005627.zip
Fix void pointer arithmetic.
git-svn-id: http://svn.drobilla.net/sord/trunk@252 3d64ff67-21c5-427c-a301-fe4f08042e5a
-rw-r--r--src/zix/digest.c15
1 files 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;