git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] archive: release refname after use

From
Jeff King <peff@peff.net>
Date
Nov 17, 2020, 00:28 UTC
Message-ID
<20201117002839.GB13516@coredump.intra.peff.net>
In-Reply-To
<7692d2f3-0a3b-91cd-c454-9725b0a395a7@web.de>
On Sat, Nov 14, 2020 at 11:01:04PM +0100, René Scharfe wrote:
Show 5 quoted lines
> parse_treeish_arg() uses dwim_ref() to set refname to a strdup'd string.
> Release it after use.  Also remove the const qualifier from the refname
> member to signify that ownership of the string is handed to the struct,
> leaving cleanup duty with the caller of parse_treeish_arg(), thus
> avoiding a cast.

Yeah, I looked at the surrounding code and agree that this is the right thing to do.

I wondered if it might make sense for the initialization and clearing of this "archive_args" structure to go in a pair of matched functions, but it probably isn't worth the trouble. write_archive() is the only place where we will allocate and deallocate such a struct (the only reason it is a type at all is to pass the set of values around the stack).

-Peff
Previous: René Scharfe
Message 2 of 2 in “archive: release refname after use”
  1. archive: release refname after useRené Scharfe, Nov 14, 2020
  2. Jeff KingNov 17, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.