Subject: Re: [PATCH 3/3] clone: Free a few paths

From: Jonathan Nieder <[email-masked]>
Date: Mon, 14 Mar 2011 14:45:01 -0500

Hi,

Carlos Martín Nieto wrote:

> Free the path, repo, dir buffers
> 
> Signed-off-by: Carlos Martín Nieto <[email-masked]>
[...]
> +	free(dir);
> +	free(repo);
> +	free(path);
>  	strbuf_release(&reflog_msg);
>  	strbuf_release(&branch_top);
>  	strbuf_release(&key);

Thanks.  The commit message should probably mention that this is for
the sake of valgrind rather a true memory leak, since the memory is
freed by _exit at the appropriate time already.

The patch itself seems sane, since the performance effect should be
negligible.

But it reminds me: does "valgrind --tool=memcheck" provide a way to
annotate allocations like these?  In other words, is it be possible to
have functions xmalloc_permanent and xstrdup_permanent that

 * allocate a buffer that is never meant to be freed;
 * do not cause valgrind to complain;
 * could be reimplemented some day by taking allocations from a large
   contiguous pool, to avoid malloc overhead and to take advantage of
   the knowledge that these allocations never need to be freed

?

Curious,
Jonathan