Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-12-13 11:04:27 +0300
committerJunio C Hamano <gitster@pobox.com>2020-12-14 01:18:20 +0300
commit89422d29b1d63004683aaa6d11faa65ba734d46f (patch)
tree6ee9f2dee9360d9e7467bd43018c485c3442ebba /merge-ort.c
parentef2b369387004f4f11497a55174d0d9859549054 (diff)
merge-ort: free data structures in merge_finalize()
Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-ort.c')
-rw-r--r--merge-ort.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/merge-ort.c b/merge-ort.c
index 47cd772e80..51b049358e 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -209,6 +209,16 @@ struct conflict_info {
assert((ci) && !(mi)->clean); \
} while (0)
+static void free_strmap_strings(struct strmap *map)
+{
+ struct hashmap_iter iter;
+ struct strmap_entry *entry;
+
+ strmap_for_each_entry(map, &iter, entry) {
+ free((char*)entry->key);
+ }
+}
+
static int err(struct merge_options *opt, const char *err, ...)
{
va_list params;
@@ -1153,7 +1163,27 @@ 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.
+ */
+ free_strmap_strings(&opti->paths);
+ strmap_clear(&opti->paths, 1);
+
+ /*
+ * All keys and values in opti->conflicted are a subset of those in
+ * opti->paths. We don't want to deallocate anything twice, so we
+ * don't free the keys and we pass 0 for free_values.
+ */
+ strmap_clear(&opti->conflicted, 0);
+ FREE_AND_NULL(opti);
}
static void merge_start(struct merge_options *opt, struct merge_result *result)