8 unsigned int strdup_strings:1;
12 struct hashmap_entry ent;
17 int cmp_strmap_entry(const void *hashmap_cmp_fn_data,
18 const struct hashmap_entry *entry1,
19 const struct hashmap_entry *entry2,
22 #define STRMAP_INIT { \
23 .map = HASHMAP_INIT(cmp_strmap_entry, NULL), \
24 .strdup_strings = 1, \
28 * Initialize the members of the strmap. Any keys added to the strmap will
29 * be strdup'ed with their memory managed by the strmap.
31 void strmap_init(struct strmap *map);
34 * Same as strmap_init, but for those who want to control the memory management
35 * carefully instead of using the default of strdup_strings=1.
37 void strmap_init_with_options(struct strmap *map,
41 * Remove all entries from the map, releasing any allocated resources.
43 void strmap_clear(struct strmap *map, int free_values);
46 * Insert "str" into the map, pointing to "data".
48 * If an entry for "str" already exists, its data pointer is overwritten, and
49 * the original data pointer returned. Otherwise, returns NULL.
51 void *strmap_put(struct strmap *map, const char *str, void *data);
54 * Return the data pointer mapped by "str", or NULL if the entry does not
57 void *strmap_get(struct strmap *map, const char *str);
60 * Return non-zero iff "str" is present in the map. This differs from
61 * strmap_get() in that it can distinguish entries with a NULL data pointer.
63 int strmap_contains(struct strmap *map, const char *str);