Subject: Re: [PATCH 1/3] remove prefix argument from pathspec_prefix

From: Clemens Buchacher <[email-masked]>
Date: Thu, 8 Sep 2011 09:12:37 +0200

On Tue, Sep 06, 2011 at 12:58:16PM -0700, Junio C Hamano wrote:
> Junio C Hamano <[email-masked]> writes:
> 
> > Is it because we no longer ever return "prefix" we pass in which is a
> > pointer to a constant memory region to begin with?
> >
> > We also didn't free() in the earlier code (because we do not know if it
> > can be freed) and leaking xmemdupz() if the function didn't return the
> > "prefix", but now you plugged the small leak. Isn't it something you
> > should advertise?
> 
> Nah, the leak is not necessarily plugged in all callers anyway, so scratch
> that part. I've rewritten it like this:

Ok.

The only other caller, though, is cmd_ls_files(). And it would be
trivial to plug that leak as well.

But is it considered a leak, if the program is going to terminate
right after the function returns? I recall that being used as an
argument against free'ing such memory on this list.

On the other hand, that practice makes it harder to analyze leaks
using memory leak detectors like for example valgrind.

Clemens