From f2605051427af9fceaacb4a9d0effc6e2b0af227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Wed, 13 Apr 2022 22:01:32 +0200 Subject: string_list API users: use string_list_init_{no,}dup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up on the introduction of string_list_init_nodup() and string_list_init_dup() in the series merged in bd4232fac33 (Merge branch 'ab/struct-init', 2021-07-16) and convert code that implicitly relied on xcalloc() being equivalent to the initializer to use xmalloc() and string_list_init_{no,}dup() instead. In the case of get_unmerged() in merge-recursive.c we used the combination of xcalloc() and assigning "1" to "strdup_strings" to get what we'd get via string_list_init_dup(), let's use that instead. Adjacent code in cmd_format_patch() will be changed in a subsequent commit, since we're changing that let's change the other in-tree patterns that do the same. Let's also convert a "x == NULL" to "!x" per our CodingGuidelines, as we need to change the "if" line anyway. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- merge-recursive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'merge-recursive.c') diff --git a/merge-recursive.c b/merge-recursive.c index 1ee6364e8b..32bbba5fbb 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -522,10 +522,10 @@ static struct stage_data *insert_stage_data(struct repository *r, */ static struct string_list *get_unmerged(struct index_state *istate) { - struct string_list *unmerged = xcalloc(1, sizeof(struct string_list)); + struct string_list *unmerged = xmalloc(sizeof(struct string_list)); int i; - unmerged->strdup_strings = 1; + string_list_init_dup(unmerged); /* TODO: audit for interaction with sparse-index. */ ensure_full_index(istate); -- cgit v1.2.3 From 2108fe4a1976f95821e13503fd331f075da398c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Wed, 13 Apr 2022 22:01:36 +0200 Subject: revisions API users: add straightforward release_revisions() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a release_revisions() to various users of "struct rev_list" in those straightforward cases where we only need to add the release_revisions() call to the end of a block, and don't need to e.g. refactor anything to use a "goto cleanup" pattern. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- merge-recursive.c | 1 + 1 file changed, 1 insertion(+) (limited to 'merge-recursive.c') diff --git a/merge-recursive.c b/merge-recursive.c index 32bbba5fbb..acd13b2b06 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1160,6 +1160,7 @@ static int find_first_merges(struct repository *repo, } object_array_clear(&merges); + release_revisions(&revs); return result->nr; } -- cgit v1.2.3