Skip to content

Commit

Permalink
use uint64_t for hash seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
balos1 committed Feb 13, 2024
1 parent 2caa860 commit b885207
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/sundials/sundials_hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
#ifndef _SUNDIALS_HASHMAP_H
#define _SUNDIALS_HASHMAP_H

#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include "sundials/sundials_errors.h"
#include "sundials/sundials_types.h"

static const unsigned long HASH_PRIME = 14695981039346656037U;
static const unsigned long HASH_OFFSET_BASIS = 1099511628211U;
static const uint64_t HASH_PRIME = 14695981039346656037U;
static const uint64_t HASH_OFFSET_BASIS = 1099511628211U;

/*
For a nice discussion on popular hashing algorithms see:
Expand All @@ -36,9 +37,9 @@ static const unsigned long HASH_OFFSET_BASIS = 1099511628211U;
This is a 64-bit implementation of the 'a' modification of the
Fowler–Noll–Vo hash (i.e., FNV1-a).
*/
static unsigned long fnv1a_hash(const char* str)
static uint64_t fnv1a_hash(const char* str)
{
unsigned long hash = HASH_OFFSET_BASIS;
uint64_t hash = HASH_OFFSET_BASIS;
char c;
while ((c = *str++)) { hash = (hash ^ c) * HASH_PRIME; }
return hash;
Expand Down

0 comments on commit b885207

Please sign in to comment.