Harlequin RIP SDK

Peter Weinberger's non-cryptographic hash implemented as an inline function. More...

Functions

static uint32 pjw_hash_seeded (const void *data, int32 datalen, uint32 hash)
 Combine a 32-bit PJW hash value from a byte buffer with an initial seed value. More...
 
static uint32 pjw_hash (const void *data, int32 datalen)
 Get a 32-bit PJW hash value from a byte buffer. More...
 

Detailed Description

Peter Weinberger's non-cryptographic hash implemented as an inline function.

This header file should ONLY be included by C files that use this hash function. Header files should not include this, if the hash function is not used by a source file that includes it, there will be warnings about unused static functions.

This simple hash function operates on a number of characters, in a single operation. If you need an incremental hash function, or a hash function that operates on larger units, or a hash function with better dispersion, try using Hsieh's SuperFastHash (hsiehhash32.h) or MurmurHash3 (murmurhash3.h).

Function Documentation

◆ pjw_hash()

static uint32 pjw_hash ( const void *  data,
int32  datalen 
)
inlinestatic

Get a 32-bit PJW hash value from a byte buffer.

Parameters
[in]dataThe data to hash.
[in]datalenThe number of 8-bit values to include in the hash key. If this is less than zero on entry, then the data is a zero-terminated string.
Returns
The PJW hash value for the data.

◆ pjw_hash_seeded()

static uint32 pjw_hash_seeded ( const void *  data,
int32  datalen,
uint32  hash 
)
inlinestatic

Combine a 32-bit PJW hash value from a byte buffer with an initial seed value.

Parameters
[in]dataThe data to hash.
[in]datalenThe number of 8-bit values to include in the hash key. If this is less than zero on entry, then the data is a zero-terminated string.
[in]hashThe seed value to use.
Returns
The PJW hash value for the data.