|
typedef struct XXH32_state_s | XXH32_state_t |
| The opaque state struct for the XXH32 streaming API.
|
|
Contains functions used in the classic 32-bit xxHash algorithm.
- Note
- XXH32 is useful for older platforms, with no or poor 64-bit performance. Note that the XXH3_family provides competitive speed for both 32-bit and 64-bit systems, and offers true 64/128 bit hash results.
- See also
- XXH64 family, XXH3_family : Other xxHash families
-
XXH32_impl for implementation details
◆ XXH32_createState
Value:
#define XXH_NAME2(A, B)
Definition xxhash.h:252
#define XXH_NAMESPACE
Definition xxhash.h:21
XXH_PUBLIC_API XXH32_state_t * XXH32_createState(void)
Definition xxhash.c:422
Allocates an XXH32_state_t.
- Returns
- An allocated pointer of XXH32_state_t on success.
-
NULL
on failure.
- Note
- Must be freed with XXH32_freeState().
◆ XXH32_state_t
The opaque state struct for the XXH32 streaming API.
- See also
- XXH32_state_s for details.
◆ XXH32()
Calculates the 32-bit hash of input
using xxHash32.
- Parameters
-
input | The block of data to be hashed, at least length bytes in size. |
length | The length of input , in bytes. |
seed | The 32-bit seed to alter the hash's output predictably. |
- Precondition
- The memory between
input
and input
+ length
must be valid, readable, contiguous memory. However, if length
is 0
, input
may be NULL
. In C++, this also must be TriviallyCopyable.
- Returns
- The calculated 32-bit xxHash32 value.
- See also
- Single Shot Example for an example.
Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark): 5.4 GB/s
- Parameters
-
input | The block of data to be hashed, at least length bytes in size. |
length | The length of input , in bytes. |
seed | The 32-bit seed to alter the hash's output predictably. |
- Precondition
- The memory between
input
and input
+ length
must be valid, readable, contiguous memory. However, if length
is 0
, input
may be NULL
. In C++, this also must be TriviallyCopyable.
- Returns
- The calculated 32-bit hash value.
- See also
- XXH64(), XXH3_64bits_withSeed(), XXH3_128bits_withSeed(), XXH128(): Direct equivalents for the other variants of xxHash.
-
XXH32_createState(), XXH32_update(), XXH32_digest(): Streaming version.
XXH32() : Calculate the 32-bit hash of sequence "length" bytes stored at memory address "input". The memory between input & input+length must be valid (allocated and read-accessible). "seed" can be used to alter the result predictably. Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s
Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark): 5.4 GB/s
- Parameters
-
input | The block of data to be hashed, at least length bytes in size. |
length | The length of input , in bytes. |
seed | The 32-bit seed to alter the hash's output predictably. |
- Precondition
- The memory between
input
and input
+ length
must be valid, readable, contiguous memory. However, if length
is 0
, input
may be NULL
. In C++, this also must be TriviallyCopyable.
- Returns
- The calculated 32-bit hash value.
- See also
- XXH64(), XXH3_64bits_withSeed(), XXH3_128bits_withSeed(), XXH128(): Direct equivalents for the other variants of xxHash.
-
XXH32_createState(), XXH32_update(), XXH32_digest(): Streaming version.
◆ XXH32_canonicalFromHash()
Converts an XXH32_hash_t to a big endian XXH32_canonical_t.
- Parameters
-
- Precondition
dst
must not be NULL
.
- See also
- Canonical Representation Example
Default XXH result types are basic unsigned 32 and 64 bits. The canonical representation follows human-readable write convention, aka big-endian (large digits first). These functions allow transformation of hash result into and from its canonical format. This way, hash values can be written into a file or buffer, remaining comparable across different systems.
- Parameters
-
- Precondition
dst
must not be NULL
.
Default XXH result types are basic unsigned 32 and 64 bits. The canonical representation follows human-readable write convention, aka big-endian (large digits first). These functions allow transformation of hash result into and from its canonical format. This way, hash values can be written into a file or buffer, remaining comparable across different systems.
◆ XXH32_copyState()
Copies one XXH32_state_t to another.
- Parameters
-
dst_state | The state to copy to. |
src_state | The state to copy from. |
- Precondition
dst_state
and src_state
must not be NULL
and must not overlap.
◆ XXH32_digest()
Returns the calculated hash value from an XXH32_state_t.
- Parameters
-
statePtr | The state struct to calculate the hash from. |
- Precondition
statePtr
must not be NULL
.
- Returns
- The calculated 32-bit xxHash32 value from that state.
- Note
- Calling XXH32_digest() will not affect
statePtr
, so you can update, digest, and update again.
-
Calling XXH32_digest() will not affect
statePtr
, so you can update, digest, and update again.
- Parameters
-
statePtr | The state struct to calculate the hash from. |
- Precondition
statePtr
must not be NULL
.
- Returns
- The calculated xxHash32 value from that state.
◆ XXH32_freeState()
◆ XXH32_hashFromCanonical()
◆ XXH32_reset()
Resets an XXH32_state_t to begin a new hash.
- Parameters
-
statePtr | The state struct to reset. |
seed | The 32-bit seed to alter the hash result predictably. |
- Precondition
statePtr
must not be NULL
.
- Returns
- XXH_OK on success.
-
XXH_ERROR on failure.
- Note
- This function resets and seeds a state. Call it before XXH32_update().
This function resets and seeds a state. Call it before XXH32_update().
- Parameters
-
statePtr | The state struct to reset. |
seed | The 32-bit seed to alter the hash result predictably. |
- Precondition
statePtr
must not be NULL
.
- Returns
- XXH_OK on success, XXH_ERROR on failure.
◆ XXH32_update()
Consumes a block of input
to an XXH32_state_t.
- Parameters
-
statePtr | The state struct to update. |
input | The block of data to be hashed, at least length bytes in size. |
length | The length of input , in bytes. |
- Precondition
statePtr
must not be NULL
.
-
The memory between
input
and input
+ length
must be valid, readable, contiguous memory. However, if length
is 0
, input
may be NULL
. In C++, this also must be TriviallyCopyable.
- Returns
- XXH_OK on success.
-
XXH_ERROR on failure.
- Note
- Call this to incrementally consume blocks of data.
Call this to incrementally consume blocks of data.
- Parameters
-
statePtr | The state struct to update. |
input | The block of data to be hashed, at least length bytes in size. |
length | The length of input , in bytes. |
- Precondition
statePtr
must not be NULL
.
-
The memory between
input
and input
+ length
must be valid, readable, contiguous memory. However, if length
is 0
, input
may be NULL
. In C++, this also must be TriviallyCopyable.
- Returns
- XXH_OK on success, XXH_ERROR on failure.