@@ -840,7 +840,29 @@ void merge_switch_to_result(struct merge_options *opt,
void merge_finalize(struct merge_options *opt,
struct merge_result *result)
{
- die("Not yet implemented");
+ struct merge_options_internal *opti = result->priv;
+
+ assert(opt->priv == NULL);
+
+ /*
+ * We marked opti->paths with strdup_strings = 0, so that we
+ * wouldn't have to make another copy of the fullpath created by
+ * make_traverse_path from setup_path_info(). But, now that we've
+ * used it and have no other references to these strings, it is time
+ * to deallocate them, which we do by just setting strdup_string = 1
+ * before the strmaps are cleared.
+ */
+ opti->paths.strdup_strings = 1;
+ strmap_clear(&opti->paths, 1);
+
+ /*
+ * All strings and util fields in opti->unmerged are a subset
+ * of those in opti->paths. We don't want to deallocate
+ * anything twice, so we don't set strdup_strings and we pass 0 for
+ * free_util.
+ */
+ strmap_clear(&opti->unmerged, 0);
+ FREE_AND_NULL(opti);
}
static void merge_start(struct merge_options *opt, struct merge_result *result)
Signed-off-by: Elijah Newren <newren@gmail.com> --- merge-ort.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)