Subject: Re: [PATCH 03/16] object_array: factor out slopbuf-freeing logic

From: Michael Haggerty <[email-masked]>
Date: Tue, 07 Oct 2014 13:25:54 +0200

On 10/03/2014 10:22 PM, Jeff King wrote:
> This is not a lot of code, but it's a logical construct that
> should not need to be repeated (and we are about to add a
> third repetition).
> 
> Signed-off-by: Jeff King <[email-masked]>
> ---
>  object.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/object.c b/object.c
> index ca9d790..14238dc 100644
> --- a/object.c
> +++ b/object.c
> @@ -355,6 +355,12 @@ void add_object_array_with_context(struct object *obj, const char *name, struct
>  		add_object_array_with_mode_context(obj, name, array, S_IFINVALID, context);
>  }
>  
> +static void object_array_release_entry(struct object_array_entry *ent)
> +{
> +	if (ent->name != object_array_slopbuf)
> +		free(ent->name);
> +}
> +

Would it be a little safer to set ent->name to NULL or to
object_array_slopbuf after freeing the memory, to prevent accidents?

> [...]

Michael

-- 
Michael Haggerty
[email-masked]