From: Derrick Stolee <stolee@gmail.com>
To: "Jeff King" <peff@peff.net>, "René Scharfe" <l.s.r@web.de>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>,
Derrick Stolee <dstolee@microsoft.com>
Subject: Re: [PATCH] commit-reach: plug minor memory leak after using is_descendant_of()
Date: Fri, 19 Jun 2020 10:07:14 -0400 [thread overview]
Message-ID: <a7621cce-b2f9-d4ce-2fca-85e23cf185c0@gmail.com> (raw)
In-Reply-To: <20200619133159.GB2540897@coredump.intra.peff.net>
On 6/19/2020 9:31 AM, Jeff King wrote:
> On Fri, Jun 19, 2020 at 03:13:46PM +0200, René Scharfe wrote:
>
>> ref_newer() builds a commit_list to pass a single potential ancestor to
>> is_descendant_of(). The latter leaves the list intact. Release the
>> allocated memory after the call.
>
> Looks obviously correct.
I concur, thanks!
>> ---
>> We could allocate the commit_list on the stack, which would simplify such
>> glue code quite a bit. That would be dangerous in case is_descendant_of()
>> or some other function that is handed such a list tries to consume/free()
>> it. How can we be tell a function is safe to be given a stack-allocated
>> list? Perhaps by marking its argument as const. Or by converting all
>> functions to arrays.
>
> Yeah, if we're not worried about the performance implications of the
> extra allocation, I think it's better to err on the side of safety.
>
> I do agree that if we consistently passed an array (and length), some of
> these functions would get less awkward. I tried a few years ago to
> convert many of the commit_list uses to arrays, but it was a bit of a
> yak shave, since often they get lists from callers, who get it from
> rev_info, etc. And some of those callers _do_ like having lists, because
> they want to do O(1) splicing, etc.
Yeah, this constant parameter-conversion between the different
methods in commit-reach.c is certainly unfortunate, but persists
due to historical reasons that Peff mentions.
Thanks,
-Stolee
prev parent reply other threads:[~2020-06-19 14:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 13:13 [PATCH] commit-reach: plug minor memory leak after using is_descendant_of() René Scharfe
2020-06-19 13:31 ` Jeff King
2020-06-19 14:07 ` Derrick Stolee [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a7621cce-b2f9-d4ce-2fca-85e23cf185c0@gmail.com \
--to=stolee@gmail.com \
--cc=dstolee@microsoft.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=l.s.r@web.de \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).