From: Patrick Steinhardt Date: Tue, 04 Jun 2024 07:43:05 GMT Subject: Re: [PATCH 13/13] sparse-checkout: free duplicate hashmap entries Message-ID: In-Reply-To: <20240531113830.GM428814@coredump.intra.peff.net> On Fri, May 31, 2024 at 07:38:30AM -0400, Jeff King wrote: > @@ -533,8 +534,14 @@ static void insert_recursive_pattern(struct pattern_list *pl, struct strbuf *pat > e->pattern = xstrndup(oldpattern, newlen); > hashmap_entry_init(&e->ent, fspathhash(e->pattern)); > > - if (!hashmap_get_entry(&pl->parent_hashmap, e, ent, NULL)) > + dup = hashmap_get_entry(&pl->parent_hashmap, e, ent, NULL); > + if (!dup) > hashmap_add(&pl->parent_hashmap, &e->ent); > + else { > + free(e->pattern); > + free(e); > + e = dup; > + } Nit: code style. The `if (!dup)` branch should also have curly braces. Patrick