libnl 3.7.0
hashtable.h
1/* SPDX-License-Identifier: LGPL-2.1-only */
2/*
3 * Copyright (c) 2012 Cumulus Networks, Inc
4 */
5
6#ifndef NETLINK_HASHTABLE_H_
7#define NETLINK_HASHTABLE_H_
8
9#include <stddef.h>
10#include <stdint.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16typedef struct nl_hash_node {
17 uint32_t key;
18 uint32_t key_size;
19 struct nl_object * obj;
20 struct nl_hash_node * next;
22
23typedef struct nl_hash_table {
24 int size;
25 nl_hash_node_t ** nodes;
27
28/* Default hash table size */
29#define NL_MAX_HASH_ENTRIES 1024
30
31/* Access Functions */
32extern nl_hash_table_t * nl_hash_table_alloc(int size);
33extern void nl_hash_table_free(nl_hash_table_t *ht);
34
36 struct nl_object *obj);
38 struct nl_object *obj);
39
40extern struct nl_object * nl_hash_table_lookup(nl_hash_table_t *ht,
41 struct nl_object *obj);
42extern uint32_t nl_hash(void *k, size_t length,
43 uint32_t initval);
44
45#ifdef __cplusplus
46}
47#endif
48
49#endif /* NETLINK_HASHTABLE_H_ */
int nl_hash_table_del(nl_hash_table_t *ht, struct nl_object *obj)
Remove object from hashtable.
Definition: hashtable.c:156
nl_hash_table_t * nl_hash_table_alloc(int size)
Allocate hashtable.
Definition: hashtable.c:24
void nl_hash_table_free(nl_hash_table_t *ht)
Free hashtable including all nodes.
Definition: hashtable.c:51
int nl_hash_table_add(nl_hash_table_t *ht, struct nl_object *obj)
Add object to hashtable.
Definition: hashtable.c:112
struct nl_object * nl_hash_table_lookup(nl_hash_table_t *ht, struct nl_object *obj)
Lookup identical object in hashtable.
Definition: hashtable.c:81