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

Re: [PATCH 3/3] for-each-ref: introduce %(upstream:track[short])

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Sep 27, 2013, 22:18 UTC
Message-ID
<20130927221845.GO9464@google.com>
In-Reply-To
<52459570.4030301@viscovery.net>
Johannes Sixt wrote:
> Am 9/27/2013 14:10, schrieb Ramkumar Ramachandra:
>> +					v->s = xstrdup(buf);
>> +				}
>
> These strdupped strings are leaked, right?

The convention seems to be that each refinfo owns its atom_value, which owns its string that is kept on the heap. Except when it isn't (e.g., "v->s = typename(obj->type);"). So at least this patch doesn't make the muddle any worse. ;-)

A nice followup would be to consistently allocate atom_value.s on the heap, check for a GIT_FREE_AT_EXIT envvar, and free the refinfos if that envvar is set at exit. That would make sure that the code is careful enough with memory to some day free some refinfo earlier when there are many refs. Until that's ready, I think continuing to mix and match like this (constant strings left as is, dynamically generated strings on the heap) is the best we can do.

Thanks, Jonathan

Previous: Ramkumar RamachandraNext: Philip Oakley
Message 10 of 13 in “Juggling between hot branches”
  1. 0/3 Juggling between hot branchesRamkumar Ramachandra, Sep 27, 2013
  2. 1/3 for-each-ref: introduce %C(...) for colorRamkumar Ramachandra, Sep 27, 2013
  3. Phil HordSep 27, 2013
  4. 2/3 for-each-ref: introduce %(HEAD) asterisk markerRamkumar Ramachandra, Sep 27, 2013
  5. 3/3 for-each-ref: introduce %(upstream:track[short])Ramkumar Ramachandra, Sep 27, 2013
  6. Phil HordSep 27, 2013
  7. Ramkumar RamachandraSep 27, 2013
  8. Johannes SixtSep 27, 2013
  9. Ramkumar RamachandraSep 27, 2013
  10. Jonathan NiederSep 27, 2013
  11. Philip OakleySep 27, 2013
  12. Ramkumar RamachandraSep 27, 2013
  13. Philip OakleySep 27, 2013

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.