1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2023 Red Hat
9 #include <linux/compiler.h>
10 #include <linux/types.h>
15 * An int_map associates pointers (void *) with integer keys (u64). NULL pointer values are
18 * The map is implemented as hash table, which should provide constant-time insert, query, and
19 * remove operations, although the insert may occasionally grow the table, which is linear in the
20 * number of entries in the map. The table will grow as needed to hold new entries, but will not
21 * shrink as entries are removed.
26 int __must_check
vdo_int_map_create(size_t initial_capacity
, struct int_map
**map_ptr
);
28 void vdo_int_map_free(struct int_map
*map
);
30 size_t vdo_int_map_size(const struct int_map
*map
);
32 void *vdo_int_map_get(struct int_map
*map
, u64 key
);
34 int __must_check
vdo_int_map_put(struct int_map
*map
, u64 key
, void *new_value
,
35 bool update
, void **old_value_ptr
);
37 void *vdo_int_map_remove(struct int_map
*map
, u64 key
);
39 #endif /* VDO_INT_MAP_H */