Smart Home firewall
Profile-based Smart Home firewall
hashmap.h
1 // Copyright 2020 Joshua J Baker. All rights reserved.
2 // Use of this source code is governed by an MIT-style
3 // license that can be found in the LICENSE file.
4 
5 #ifndef HASHMAP_H
6 #define HASHMAP_H
7 
8 #include <stdbool.h>
9 #include <stddef.h>
10 #include <stdint.h>
11 
12 typedef struct hashmap hashmap;
13 
14 struct hashmap *hashmap_new(size_t elsize, size_t cap,
15  uint64_t seed0, uint64_t seed1,
16  uint64_t (*hash)(const void *item,
17  uint64_t seed0, uint64_t seed1),
18  int (*compare)(const void *a, const void *b,
19  void *udata),
20  void (*elfree)(void *item),
21  void *udata);
22 struct hashmap *hashmap_new_with_allocator(
23  void *(*malloc)(size_t),
24  void *(*realloc)(void *, size_t),
25  void (*free)(void*),
26  size_t elsize, size_t cap,
27  uint64_t seed0, uint64_t seed1,
28  uint64_t (*hash)(const void *item,
29  uint64_t seed0, uint64_t seed1),
30  int (*compare)(const void *a, const void *b,
31  void *udata),
32  void (*elfree)(void *item),
33  void *udata);
34 void hashmap_free(struct hashmap *map);
35 void hashmap_clear(struct hashmap *map, bool update_cap);
36 size_t hashmap_count(struct hashmap *map);
37 bool hashmap_oom(struct hashmap *map);
38 void *hashmap_get(struct hashmap *map, const void *item);
39 void *hashmap_set(struct hashmap *map, const void *item);
40 void *hashmap_delete(struct hashmap *map, void *item);
41 void *hashmap_probe(struct hashmap *map, uint64_t position);
42 bool hashmap_scan(struct hashmap *map,
43  bool (*iter)(const void *item, void *udata), void *udata);
44 bool hashmap_iter(struct hashmap *map, size_t *i, void **item);
45 
46 uint64_t hashmap_sip(const void *data, size_t len,
47  uint64_t seed0, uint64_t seed1);
48 uint64_t hashmap_murmur(const void *data, size_t len,
49  uint64_t seed0, uint64_t seed1);
50 
51 
52 // DEPRECATED: use `hashmap_new_with_allocator`
53 void hashmap_set_allocator(void *(*malloc)(size_t), void (*free)(void*));
54 
55 #endif /* HASHMAP_H */
Definition: hashmap.c:37