Re: [PATCH 2/7] reset: free instead of leaking unneeded ref
- From
Jeff King <peff@peff.net>
- Date
- Mar 8, 2021, 19:03 UTC
- Message-ID
- <YEZ0/GI9A5FWHhMG@coredump.intra.peff.net>
- In-Reply-To
- <a7b6b873460fe096a3441c3a8d4d766b7221f14d.1615228580.git.gitgitgadget@gmail.com>
On Mon, Mar 08, 2021 at 06:36:15PM +0000, Andrzej Hunt via GitGitGadget wrote:
Show 7 quoted lines
> dwim_ref() allocs a new string into ref. Instead of setting to NULL to discard > it, we can FREE_AND_NULL. > [...] > dwim_ref(rev, strlen(rev), &dummy, &ref, 0); > if (ref && !starts_with(ref, "refs/")) > - ref = NULL; > + FREE_AND_NULL(ref);
Yeah, this seems like a perfect solution for this case.
-Peff