7 * struct oidmap_entry is a structure representing an entry in the hash table,
8 * which must be used as first member of user data structures.
10 * Users should set the oid field. oidmap_put() will populate the
11 * internal_entry field.
14 /* For internal use only */
15 struct hashmap_entry internal_entry;
24 #define OIDMAP_INIT { { NULL } }
27 * Initializes an oidmap structure.
29 * `map` is the oidmap to initialize.
31 * If the total number of entries is known in advance, the `initial_size`
32 * parameter may be used to preallocate a sufficiently large table and thus
33 * prevent expensive resizing. If 0, the table is dynamically resized.
35 extern void oidmap_init(struct oidmap *map, size_t initial_size);
38 * Frees an oidmap structure and allocated memory.
40 * If `free_entries` is true, each oidmap_entry in the map is freed as well
41 * using stdlibs free().
43 extern void oidmap_free(struct oidmap *map, int free_entries);
46 * Returns the oidmap entry for the specified oid, or NULL if not found.
48 extern void *oidmap_get(const struct oidmap *map,
49 const struct object_id *key);
52 * Adds or replaces an oidmap entry.
54 * ((struct oidmap_entry *) entry)->internal_entry will be populated by this
57 * Returns the replaced entry, or NULL if not found (i.e. the entry was added).
59 extern void *oidmap_put(struct oidmap *map, void *entry);
62 * Removes an oidmap entry matching the specified oid.
64 * Returns the removed entry, or NULL if not found.
66 extern void *oidmap_remove(struct oidmap *map, const struct object_id *key);