@@ -245,7 +245,7 @@ void hashmap_free_(struct hashmap *map, ssize_t offset);
* where @member is the hashmap_entry struct used to associate with @map
*/
#define hashmap_free_entries(map, type, member) \
- hashmap_free_(map, offsetof(type, member));
+ hashmap_free_(map, offsetof(type, member))
/* hashmap_entry functions */
@@ -26,8 +26,10 @@ void oidmap_free(struct oidmap *map, int free_entries)
if (!map)
return;
- /* TODO: make oidmap itself not depend on struct layouts */
- hashmap_free_(&map->map, free_entries ? 0 : -1);
+ if (free_entries)
+ hashmap_free_entries(&map->map, struct oidmap_entry, internal_entry);
+ else
+ hashmap_free(&map->map);
}
void *oidmap_get(const struct oidmap *map, const struct object_id *key)
c8e424c9 (hashmap: introduce hashmap_free_entries, 2019-10-06) introduced hashmap_free_entries(), which can free any struct pointer, regardless of the hashmap_entry field offset. oidmap does not make use of this flexibilty, hardcoding the offset to zero instead. Let's fix this by passing struct type and member to hashmap_free_entries(). Additionally, remove an erroneous semi-colon at the end of hashmap_free_entries() macro. Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com> --- Changes in v2: - Fix references to earlier commits. - Grammar fixes. hashmap.h | 2 +- oidmap.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)