Re: [PATCH 3/3] clone: Free a few paths
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Mar 14, 2011, 19:45 UTC
- Message-ID
- <20110314194501.GA30483@elie>
- In-Reply-To
- <1300130318-11279-4-git-send-email-cmn@elego.de>
Hi,
Carlos Martín Nieto wrote:
> Free the path, repo, dir buffers > > Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
[...]
Show 6 quoted lines
> + 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