Skip to content

Commit 9f889ff

Browse files
committed
sequencer: use oidmap_clear_with_free() for string_entry cleanup
Switch cleanup of the string_entry oidmap to oidmap_clear_with_free() and introduce a free_string_entry() helper to properly free each allocated struct string_entry. This aligns with the ongoing migration to use the callback-based oidmap cleanup API. Signed-off-by: Seyi Kuforiji <kuforiji98@gmail.com>
1 parent ac712a2 commit 9f889ff

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sequencer.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5654,6 +5654,12 @@ struct string_entry {
56545654
char string[FLEX_ARRAY];
56555655
};
56565656

5657+
static void free_string_entry(void *e)
5658+
{
5659+
struct string_entry *entry = container_of(e, struct string_entry, entry);
5660+
free(entry);
5661+
}
5662+
56575663
struct label_state {
56585664
struct oidmap commit2label;
56595665
struct hashmap labels;
@@ -6044,8 +6050,8 @@ static int make_script_with_merges(struct pretty_print_context *pp,
60446050
oidset_clear(&interesting);
60456051
oidset_clear(&child_seen);
60466052
oidset_clear(&shown);
6047-
oidmap_clear(&commit2todo, 1);
6048-
oidmap_clear(&state.commit2label, 1);
6053+
oidmap_clear_with_free(&commit2todo, free_string_entry);
6054+
oidmap_clear_with_free(&state.commit2label, free_string_entry);
60496055
hashmap_clear_and_free(&state.labels, struct labels_entry, entry);
60506056
strbuf_release(&state.buf);
60516057

0 commit comments

Comments
 (0)