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

Re: [RFH] lifetime rule for url parameter to transport_get()?

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Aug 23, 2011, 17:04 UTC
Message-ID
<alpine.LNX.2.00.1108231252520.2056@iabervon.org>
In-Reply-To
<7vsjosrs0w.fsf@alter.siamese.dyndns.org>
On Tue, 23 Aug 2011, Junio C Hamano wrote:
Show 14 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > Does anybody remember why we use a copied string of "ref_git_copy" in
> > builtin/clone.c::setup_reference()?
> >
> > 	ref_git = real_path(option_reference);
> > 	...
> > 	ref_git_copy = xstrdup(ref_git);
> 
> It didn't have anything to do with transport/remote layer.
> 
> This codepath uses real_path() and optionally mkpath(), both of which
> returns a short-lived static buffer to return its findings, and long-term
> users are expected to copy it away.

Yeah, that fits with my expectation, given the lack of a comment and the fact that you were asking about clone and not also fetch.

At least originally, the remote and transport data was expected to live until the process exits, since it's a small, bounded number of small objects. If I'd included functions to free the structures, I'd have had them free the strings they were passed.

	-Daniel
*This .sig left intentionally blank*
Previous: Junio C Hamano
Message 3 of 3 in “[RFH] lifetime rule for url parameter to transport_get()?”
  1. Junio C HamanoAug 23, 2011
  2. Junio C HamanoAug 23, 2011
  3. Daniel BarkalowAug 23, 2011

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.