summaryrefslogtreecommitdiffstats
path: root/src/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hash.c')
-rw-r--r--src/hash.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/hash.c b/src/hash.c
new file mode 100644
index 0000000..cfdafc3
--- /dev/null
+++ b/src/hash.c
@@ -0,0 +1,15 @@
+#include "hash.h"
+#include <assert.h>
+
+uint64_t vgltf_hash_fnv_1a(const char *bytes, size_t nbytes) {
+ assert(bytes);
+ static const uint64_t FNV_OFFSET_BASIS = 14695981039346656037u;
+ static const uint64_t FNV_PRIME = 1099511628211u;
+ uint64_t hash = FNV_OFFSET_BASIS;
+ for (size_t i = 0; i < nbytes; i++) {
+ hash = hash ^ bytes[i];
+ hash = hash * FNV_PRIME;
+ }
+
+ return hash;
+}
Go back to lisible.xyz