"dereferencing type-punned pointer will break strict-aliasing rules"
See man gcc, -fstrict-aliasing
Signed-off-by: Benjamin Poirier <benjamin.poirier@polymtl.ca>
guint ghfDatagramKeyHash(gconstpointer key)
{
DatagramKey* datagramKey;
+ union {
+ uint8_t byteKey[8];
+ uint32_t hashableKey[2];
+ } dataKey;
uint32_t a, b, c;
datagramKey= (DatagramKey*) key;
+ memcpy(dataKey.byteKey, datagramKey->dataKey, sizeof(dataKey.byteKey));
a= datagramKey->saddr;
b= datagramKey->daddr;
mix(a, b, c);
a+= datagramKey->ulen; // 16 bits left here
- b+= *((uint32_t*) datagramKey->dataKey);
- c+= *((uint32_t*) ((void*) datagramKey->dataKey + 4));
+ b+= dataKey.hashableKey[0];
+ c+= dataKey.hashableKey[1];
final(a, b, c);
return c;