From: Junio C Hamano Date: Mon, 02 Mar 2026 22:35:31 GMT Subject: Re: [PATCH v2 4/5] odb: use oidmap_clear_with_free() to release replace_map entries Message-ID: In-Reply-To: <20260302200018.75731-5-kuforiji98@gmail.com> Seyi Kuforiji writes: > +static void free_replace_map_entry(void *e) > +{ > + struct replace_object *entry = > + container_of(e, struct replace_object, original); > + free(entry); > +} > + The same comment as [PATCH v2 3/5]. > @@ -1109,7 +1117,8 @@ void odb_free(struct object_database *o) > > free(o->alternate_db); > > - oidmap_clear(&o->replace_map, 1); > + if (o->replace_map_initialized) > + oidmap_clear_with_free(&o->replace_map, free_replace_map_entry); It is a bit unfortunate that we need to know how o->replace_map is initialized and maintained. I wondered if we can do this without peeking into o->replace_map_initialized, but o->replace_map is already an instance of the map, not a pointer that points at a lazily initialized instance of a map, so that cannot be done (and we would not have replace_map_initialized member in the object_database struct in the first place, if we can tell if o.replace_map needs clearing by simply looking at it). So, all OK, I guess. > pthread_mutex_destroy(&o->replace_mutex); > > odb_close(o);