| 39 | } |
| 40 | |
| 41 | static void strmap_free_entries_(struct strmap *map, int free_values) |
| 42 | { |
| 43 | struct hashmap_iter iter; |
| 44 | struct strmap_entry *e; |
| 45 | |
| 46 | if (!map) |
| 47 | return; |
| 48 | |
| 49 | if (!free_values && map->pool) |
| 50 | /* Memory other than util is owned by and freed with the pool */ |
| 51 | return; |
| 52 | |
| 53 | /* |
| 54 | * We need to iterate over the hashmap entries and free |
| 55 | * e->key and e->value ourselves; hashmap has no API to |
| 56 | * take care of that for us. Since we're already iterating over |
| 57 | * the hashmap, though, might as well free e too and avoid the need |
| 58 | * to make some call into the hashmap API to do that. |
| 59 | */ |
| 60 | hashmap_for_each_entry(&map->map, &iter, e, ent) { |
| 61 | if (free_values) |
| 62 | free(e->value); |
| 63 | if (!map->pool) |
| 64 | free(e); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | void strmap_clear(struct strmap *map, int free_values) |
| 69 | { |
no outgoing calls
no test coverage detected