Skip to content

Commit 84a548d

Browse files
newrengitster
authored andcommitted
merge-recursive: make a helper function for cleanup for handle_renames
In anticipation of more involved cleanup to come, make a helper function for doing the cleanup at the end of handle_renames. Rename the already existing cleanup_rename[s]() to final_cleanup_rename[s](), name the new helper initial_cleanup_rename(), and leave the big comment in the code about why we can't do all the cleanup at once. Reviewed-by: Stefan Beller <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3f64687 commit 84a548d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

merge-recursive.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,12 @@ struct rename_info {
16581658
struct string_list *merge_renames;
16591659
};
16601660

1661+
static void initial_cleanup_rename(struct diff_queue_struct *pairs)
1662+
{
1663+
free(pairs->queue);
1664+
free(pairs);
1665+
}
1666+
16611667
static int handle_renames(struct merge_options *o,
16621668
struct tree *common,
16631669
struct tree *head,
@@ -1688,16 +1694,13 @@ static int handle_renames(struct merge_options *o,
16881694
* data structures are still needed and referenced in
16891695
* process_entry(). But there are a few things we can free now.
16901696
*/
1691-
1692-
free(head_pairs->queue);
1693-
free(head_pairs);
1694-
free(merge_pairs->queue);
1695-
free(merge_pairs);
1697+
initial_cleanup_rename(head_pairs);
1698+
initial_cleanup_rename(merge_pairs);
16961699

16971700
return clean;
16981701
}
16991702

1700-
static void cleanup_rename(struct string_list *rename)
1703+
static void final_cleanup_rename(struct string_list *rename)
17011704
{
17021705
const struct rename *re;
17031706
int i;
@@ -1713,10 +1716,10 @@ static void cleanup_rename(struct string_list *rename)
17131716
free(rename);
17141717
}
17151718

1716-
static void cleanup_renames(struct rename_info *re_info)
1719+
static void final_cleanup_renames(struct rename_info *re_info)
17171720
{
1718-
cleanup_rename(re_info->head_renames);
1719-
cleanup_rename(re_info->merge_renames);
1721+
final_cleanup_rename(re_info->head_renames);
1722+
final_cleanup_rename(re_info->merge_renames);
17201723
}
17211724

17221725
static struct object_id *stage_oid(const struct object_id *oid, unsigned mode)
@@ -2119,7 +2122,7 @@ int merge_trees(struct merge_options *o,
21192122
}
21202123

21212124
cleanup:
2122-
cleanup_renames(&re_info);
2125+
final_cleanup_renames(&re_info);
21232126

21242127
string_list_clear(entries, 1);
21252128
free(entries);

0 commit comments

Comments
 (0)