@@ -32,6 +32,14 @@ void *oidmap_get(const struct oidmap *map, const struct object_id *key)
return hashmap_get_from_hash(&map->map, oidhash(key), key);
}
+void *oidmap_get_next(const struct oidmap *map, const void *entry)
+{
+ if (!map->map.cmpfn)
+ return NULL;
+
+ return hashmap_get_next(&map->map, entry);
+}
+
void *oidmap_remove(struct oidmap *map, const struct object_id *key)
{
struct hashmap_entry entry;
@@ -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);
+/*
+ * Returns the next equal oidmap entry, or NULL if not found. This can be
+ * used to iterate over duplicate entries (see `oidmap_add`).
+ */
+void *oidmap_get_next(const struct oidmap *map, const void *entry);
+
/*
* Adds an oidmap entry. This allows to add duplicate entries (i.e.
* separate values with the same oid key).
For now "oidmap.h" gives us no way to get all the entries that have the same oid key from an oidmap, as oidmap_get() will always return the first entry. So let's add oidmap_get_next() for this purpose. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> --- oidmap.c | 8 ++++++++ oidmap.h | 6 ++++++ 2 files changed, 14 insertions(+)