MCPcopy Create free account
hub / github.com/git/git / strmap_free_entries_

Function strmap_free_entries_

strmap.c:41–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41static 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
68void strmap_clear(struct strmap *map, int free_values)
69{

Callers 2

strmap_clearFunction · 0.85
strmap_partial_clearFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected