Skip to content

Commit ffc16c4

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 e5257b2 commit ffc16c4

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
@@ -1668,6 +1668,12 @@ struct rename_info {
16681668
struct string_list *merge_renames;
16691669
};
16701670

1671+
static void initial_cleanup_rename(struct diff_queue_struct *pairs)
1672+
{
1673+
free(pairs->queue);
1674+
free(pairs);
1675+
}
1676+
16711677
static int handle_renames(struct merge_options *o,
16721678
struct tree *common,
16731679
struct tree *head,
@@ -1698,16 +1704,13 @@ static int handle_renames(struct merge_options *o,
16981704
* data structures are still needed and referenced in
16991705
* process_entry(). But there are a few things we can free now.
17001706
*/
1701-
1702-
free(head_pairs->queue);
1703-
free(head_pairs);
1704-
free(merge_pairs->queue);
1705-
free(merge_pairs);
1707+
initial_cleanup_rename(head_pairs);
1708+
initial_cleanup_rename(merge_pairs);
17061709

17071710
return clean;
17081711
}
17091712

1710-
static void cleanup_rename(struct string_list *rename)
1713+
static void final_cleanup_rename(struct string_list *rename)
17111714
{
17121715
const struct rename *re;
17131716
int i;
@@ -1723,10 +1726,10 @@ static void cleanup_rename(struct string_list *rename)
17231726
free(rename);
17241727
}
17251728

1726-
static void cleanup_renames(struct rename_info *re_info)
1729+
static void final_cleanup_renames(struct rename_info *re_info)
17271730
{
1728-
cleanup_rename(re_info->head_renames);
1729-
cleanup_rename(re_info->merge_renames);
1731+
final_cleanup_rename(re_info->head_renames);
1732+
final_cleanup_rename(re_info->merge_renames);
17301733
}
17311734

17321735
static struct object_id *stage_oid(const struct object_id *oid, unsigned mode)
@@ -2129,7 +2132,7 @@ int merge_trees(struct merge_options *o,
21292132
}
21302133

21312134
cleanup:
2132-
cleanup_renames(&re_info);
2135+
final_cleanup_renames(&re_info);
21332136

21342137
string_list_clear(entries, 1);
21352138
free(entries);

0 commit comments

Comments
 (0)