···5#include "object.h"
6#include "list.h"
7#include "oidset.h"
08#include "thread-utils.h"
910struct oidmap;
···109 * Objects that should be substituted by other objects
110 * (see git-replace(1)).
111 */
112- struct oidmap *replace_map;
113 unsigned replace_map_initialized : 1;
114 pthread_mutex_t replace_mutex; /* protect object replace functions */
115
···5#include "object.h"
6#include "list.h"
7#include "oidset.h"
8+#include "oidmap.h"
9#include "thread-utils.h"
1011struct oidmap;
···110 * Objects that should be substituted by other objects
111 * (see git-replace(1)).
112 */
113+ struct oidmap replace_map;
114 unsigned replace_map_initialized : 1;
115 pthread_mutex_t replace_mutex; /* protect object replace functions */
116
+1-1
oidmap.c
···22 hashmap_init(&map->map, oidmap_neq, NULL, initial_size);
23}
2425-void oidmap_free(struct oidmap *map, int free_entries)
26{
27 if (!map)
28 return;
···22 hashmap_init(&map->map, oidmap_neq, NULL, initial_size);
23}
2425+void oidmap_clear(struct oidmap *map, int free_entries)
26{
27 if (!map)
28 return;
+7-2
oidmap.h
···36void oidmap_init(struct oidmap *map, size_t initial_size);
3738/*
39- * Frees an oidmap structure and allocated memory.
040 *
41 * If `free_entries` is true, each oidmap_entry in the map is freed as well
42 * using stdlibs free().
43 */
44-void oidmap_free(struct oidmap *map, int free_entries);
4546/*
47 * Returns the oidmap entry for the specified oid, or NULL if not found.
···66 */
67void *oidmap_remove(struct oidmap *map, const struct object_id *key);
6800006970struct oidmap_iter {
71 struct hashmap_iter h_iter;
···36void oidmap_init(struct oidmap *map, size_t initial_size);
3738/*
39+ * Clear an oidmap, freeing any allocated memory. The map is empty and
40+ * can be reused without another explicit init.
41 *
42 * If `free_entries` is true, each oidmap_entry in the map is freed as well
43 * using stdlibs free().
44 */
45+void oidmap_clear(struct oidmap *map, int free_entries);
4647/*
48 * Returns the oidmap entry for the specified oid, or NULL if not found.
···67 */
68void *oidmap_remove(struct oidmap *map, const struct object_id *key);
6970+static inline unsigned int oidmap_get_size(struct oidmap *map)
71+{
72+ return hashmap_get_size(&map->map);
73+}
7475struct oidmap_iter {
76 struct hashmap_iter h_iter;