siphash24: change result argument to uint64_t

Change the "out" parameter from uint8_t[8] to uint64_t. On architectures which
enforce pointer alignment this fixes crashes when we previously cast an
unaligned array to uint64_t*, and on others this should at least improve
performance as the compiler now aligns these properly.

This also simplifies the code in most cases by getting rid of typecasts. The
only place which we can't change is struct duid's en.id, as that is _packed_
and public API, so we can't enforce alignment of the "id" field and have to
use memcpy instead.
This commit is contained in:
Martin Pitt
2015-11-16 15:20:29 +01:00
committed by Daniel Mack
parent 8dd85afe76
commit dbe81cbd2a
17 changed files with 39 additions and 37 deletions
+1 -1
View File
@@ -380,7 +380,7 @@ static unsigned base_bucket_hash(HashmapBase *h, const void *p) {
h->hash_ops->hash(p, &state);
siphash24_finalize((uint8_t*)&hash, &state);
siphash24_finalize(&hash, &state);
return (unsigned) (hash % n_buckets(h));
}