Stefan Beller <sbel...@google.com> writes:

> Usually when using string lists it looks like:
>     struct string_list a = STRING_LIST_INIT_NODUP;
>     // do stuff with a such as
>     string_list_insert(&a, "test string");
>     print_string_list(&a, "test prefix");
>     // Cleaning up works on everything inside the struct, not on the
>     // struct itself:
>     string_list_clear(&a);
>
> But as we deal with the pointers to the string lists directly, we also
> need to free the actual struct.

In other words, these two were allocated for the sole use of this
fuction by get_renames(), so this function is responsible for
freeing it?

Sounds sensible.

> Signed-off-by: Stefan Beller <sbel...@google.com>
> ---
>  merge-recursive.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/merge-recursive.c b/merge-recursive.c
> index 771f5e2..1c9c30d 100644
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -1858,6 +1858,9 @@ int merge_trees(struct merge_options *o,
>               string_list_clear(re_head, 0);
>               string_list_clear(entries, 1);
>  
> +             free(re_merge);
> +             free(re_head);
> +             free(entries);
>       }
>       else
>               clean = 1;
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to