forked from carbonengine/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCCPHash.cpp
More file actions
31 lines (23 loc) · 722 Bytes
/
CCPHash.cpp
File metadata and controls
31 lines (23 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright © 2025 CCP ehf.
#include "include/CCPHash.h"
/// See http://www.isthe.com/chongo/tech/comp/fnv/ for a description of the FNV1 hash algorithm
/// and the specific values used here.
const unsigned int FNV1_INITIAL_VALUE = 2166136261U;
const unsigned int FNV1_PRIME = 16777619U;
unsigned int CcpHashFNV1( const void* pInput, size_t nLength )
{
return CcpHashFNV1( pInput, nLength, FNV1_INITIAL_VALUE );
}
unsigned int CcpHashFNV1( const void* pInput, size_t nLength, unsigned int inputHash )
{
const int8_t* p = static_cast<const int8_t*>( pInput );
const int8_t* pEnd = p + nLength;
unsigned int hash = inputHash;
while( p < pEnd )
{
hash *= FNV1_PRIME;
hash ^= *p;
++p;
}
return hash;
}