blob: c5cfc627fdefca7be84d4f8ec2fab344ca27687c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
/*
* Copyright (c) 2023 Marc Pervaz Boocha
*
* SPDX-License-Identifier: MIT
*/
#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;
}
|