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

> `old` is not used outside the loop and would get lost
> once we reach the goto.
>
> Signed-off-by: Stefan Beller <sbel...@google.com>
> ---
>  builtin/update-index.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/builtin/update-index.c b/builtin/update-index.c
> index 5878986..6271b54 100644
> --- a/builtin/update-index.c
> +++ b/builtin/update-index.c
> @@ -584,6 +584,7 @@ static int do_reupdate(int ac, const char **av,
>               path = xstrdup(ce->name);
>               update_one(path);
>               free(path);
> +             free(old);

The change looks trivially correct.

A tangent; I wonder if we want to make path a strbuf that is
declared in the function scope, reset (not released) at each
iteration of the loop and released after the loop; keep allocating
and freeing a small piece of string all the time feels somewhat
wasteful.

Also, we might want to add to the "Be careful" comment to describe
why this cannot just be a call to "update_one(ce->name)" that does
not use "path".

--
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