@@ -43,6 +43,17 @@ void *oidmap_remove(struct oidmap *map, const struct object_id *key)
return hashmap_remove(&map->map, &entry, key);
}
+void oidmap_add(struct oidmap *map, void *entry)
+{
+ struct oidmap_entry *to_put = entry;
+
+ if (!map->map.cmpfn)
+ oidmap_init(map, 0);
+
+ hashmap_entry_init(&to_put->internal_entry, oidhash(&to_put->oid));
+ hashmap_add(&map->map, to_put);
+}
+
void *oidmap_put(struct oidmap *map, void *entry)
{
struct oidmap_entry *to_put = entry;
@@ -53,3 +64,4 @@ void *oidmap_put(struct oidmap *map, void *entry)
hashmap_entry_init(&to_put->internal_entry, oidhash(&to_put->oid));
return hashmap_put(&map->map, to_put);
}
+
@@ -49,6 +49,12 @@ void oidmap_free(struct oidmap *map, int free_entries);
void *oidmap_get(const struct oidmap *map,
const struct object_id *key);
+/*
+ * Adds an oidmap entry. This allows to add duplicate entries (i.e.
+ * separate values with the same oid key).
+ */
+void oidmap_add(struct oidmap *map, void *entry);
+
/*
* Adds or replaces an oidmap entry.
*
We will need to have more than one entry with the same oid key in an oidmap, which is not supported yet, as oipmap_put() replaces an existing entry with the same oid key. So let's add oidmap_add(). Signed-off-by: Christian Couder <chriscool@tuxfamily.org> --- oidmap.c | 12 ++++++++++++ oidmap.h | 6 ++++++ 2 files changed, 18 insertions(+)