ftwin 0.8.10
key_hash.c
1#include "key_hash.h"
2#include <stdint.h>
3
4#define XXH_STATIC_LINKING_ONLY
5#include "xxhash.h"
6
7/* --- Correct apr_off_t (64-bit) Callbacks --- */
8
9apr_size_t ft_fsize_get_key_len(const void *data)
10{
11 return sizeof(apr_off_t);
12}
13
14apr_uint32_t apr_off_t_key_hash(const void *key, apr_size_t klen)
15{
16 /* Use XXH32 to hash the 64-bit file size key */
17 return XXH32(key, sizeof(apr_off_t), 0);
18}
19
20int apr_off_t_key_cmp(const void *key1, const void *key2, apr_size_t len)
21{
22 apr_off_t i1 = *(apr_off_t *) key1;
23 apr_off_t i2 = *(apr_off_t *) key2;
24 if (i1 == i2)
25 return 0;
26 if (i1 < i2)
27 return -1;
28 return 1;
29}
30
31/* --- Correct gid_t Callbacks --- */
32
33apr_size_t ft_gid_get_key_len(const void *data)
34{
35 return sizeof(gid_t);
36}
37
38apr_uint32_t gid_t_key_hash(const void *key, apr_size_t klen)
39{
40 /* Use XXH32 to hash the gid_t key */
41 return XXH32(key, sizeof(gid_t), 0);
42}
43
44int gid_t_key_cmp(const void *key1, const void *key2, apr_size_t len)
45{
46 gid_t i1 = *(gid_t *) key1;
47 gid_t i2 = *(gid_t *) key2;
48 if (i1 == i2)
49 return 0;
50 if (i1 < i2)
51 return -1;
52 return 1;
53}
XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32(const void *input, size_t length, XXH32_hash_t seed)
Calculates the 32-bit hash of input using xxHash32.