diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-10-10 14:22:27 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-10-10 14:22:29 -0700 |
| commit | 31bc4454de66c22bc8570fd3af52a99843ac69b0 (patch) | |
| tree | 605cb77cc73bdece2a856d2a34286aa4f2bb780c /pseudo-merge.c | |
| parent | Merge branch 'ds/line-log-asan-fix' (diff) | |
| parent | builtin/send-pack: fix leaking list of push options (diff) | |
| download | git-31bc4454de66c22bc8570fd3af52a99843ac69b0.tar.gz git-31bc4454de66c22bc8570fd3af52a99843ac69b0.zip | |
Merge branch 'ps/leakfixes-part-8'
More leakfixes.
* ps/leakfixes-part-8: (23 commits)
builtin/send-pack: fix leaking list of push options
remote: fix leaking push reports
t/helper: fix leaks in proc-receive helper
pack-write: fix return parameter of `write_rev_file_order()`
revision: fix leaking saved parents
revision: fix memory leaks when rewriting parents
midx-write: fix leaking buffer
pack-bitmap-write: fix leaking OID array
pseudo-merge: fix leaking strmap keys
pseudo-merge: fix various memory leaks
line-log: fix several memory leaks
diff: improve lifecycle management of diff queues
builtin/revert: fix leaking `gpg_sign` and `strategy` config
t/helper: fix leaking repository in partial-clone helper
builtin/clone: fix leaking repo state when cloning with bundle URIs
builtin/pack-redundant: fix various memory leaks
builtin/stash: fix leaking `pathspec_from_file`
submodule: fix leaking submodule entry list
wt-status: fix leaking buffer with sparse directories
shell: fix leaking strings
...
Diffstat (limited to 'pseudo-merge.c')
| -rw-r--r-- | pseudo-merge.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/pseudo-merge.c b/pseudo-merge.c index 10ebd9a4e9..bb59965ed2 100644 --- a/pseudo-merge.c +++ b/pseudo-merge.c @@ -87,7 +87,7 @@ static void pseudo_merge_group_init(struct pseudo_merge_group *group) { memset(group, 0, sizeof(struct pseudo_merge_group)); - strmap_init_with_options(&group->matches, NULL, 0); + strmap_init_with_options(&group->matches, NULL, 1); group->decay = DEFAULT_PSEUDO_MERGE_DECAY; group->max_merges = DEFAULT_PSEUDO_MERGE_MAX_MERGES; @@ -97,6 +97,25 @@ static void pseudo_merge_group_init(struct pseudo_merge_group *group) group->stable_size = DEFAULT_PSEUDO_MERGE_STABLE_SIZE; } +void pseudo_merge_group_release(struct pseudo_merge_group *group) +{ + struct hashmap_iter iter; + struct strmap_entry *e; + + regfree(group->pattern); + free(group->pattern); + + strmap_for_each_entry(&group->matches, &iter, e) { + struct pseudo_merge_matches *matches = e->value; + free(matches->stable); + free(matches->unstable); + free(matches); + } + strmap_clear(&group->matches, 0); + + free(group->merges); +} + static int pseudo_merge_config(const char *var, const char *value, const struct config_context *ctx, void *cb_data) @@ -256,7 +275,7 @@ static int find_pseudo_merge_group_for_ref(const char *refname, matches = strmap_get(&group->matches, group_name.buf); if (!matches) { matches = xcalloc(1, sizeof(*matches)); - strmap_put(&group->matches, strbuf_detach(&group_name, NULL), + strmap_put(&group->matches, group_name.buf, matches); } |
