}
}
-static void clear_internal_opts(struct merge_options_internal *opti,
- int reinitialize)
+static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
+ int reinitialize)
{
- assert(!reinitialize);
+ void (*strmap_func)(struct strmap *, int) =
+ reinitialize ? strmap_partial_clear : strmap_clear;
/*
* We marked opti->paths with strdup_strings = 0, so that we
* to deallocate them.
*/
free_strmap_strings(&opti->paths);
- strmap_clear(&opti->paths, 1);
+ strmap_func(&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);
+ strmap_func(&opti->conflicted, 0);
/*
* opti->paths_to_free is similar to opti->paths; we created it with
assert(opt->priv == NULL);
- clear_internal_opts(opti, 0);
+ clear_or_reinit_internal_opts(opti, 0);
FREE_AND_NULL(opti);
}