aboutsummaryrefslogtreecommitdiffstats
path: root/src/mem/memhash.c
blob: d752fed4fc7e11086f2db6e81bd46dd416703f49 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <limits.h>
#include <stdint.h>
#include <mem.h>

size_t calt_memhash(const void *ptr, size_t count) {
	unsigned char const *p = ptr;
	size_t hash = 0;
	size_t const hash_bits = sizeof hash;
	while (count-- > 0) {
		hash ^= (size_t) * (p++) << count % hash_bits * CHAR_BIT;
	}
	return hash;
}