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

Re: [PATCHv3 3/6] line-log.c: fix a memleak

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 31, 2015, 19:03 UTC
Message-ID
<xmqqr3s5q9an.fsf@gitster.dls.corp.google.com>
In-Reply-To
<551A323F.9030305@gmail.com>
Stefan Beller <stefanbeller@gmail.com> writes:
Show 7 quoted lines
> On 30.03.2015 22:06, Junio C Hamano wrote:
>> If add-line-range does not take ownership of
>> parent_range from us, shouldn't we be freeing it whether we called
>> it or not???
>
> In my understanding it does take ownership of it. (According to my code
> review on friday)
Hmmm.

add_line_range() is given the "parent_range" as its third parameter, i.e. "range".

If there is nothing for the commit yet, it calls line_log_data_copy() on it to make a deep copy and stores that in new, which is then used as the decoration for the commit---the copy is what is retained.

I am not quite sure what the lifetime rule is for the original of this deep copy, i.e. "range", aka "parent_range" of the caller. Who holds pointers into it after this function is done?

Previous: Stefan BellerNext: Stefan Beller
Message 9 of 16 in “[PATCHv3 0/6] Memory leaks once again”
  1. Stefan BellerMar 31, 2015
  2. 1/6 shallow: fix a memleakStefan Beller, Mar 31, 2015
  3. Eric SunshineMar 31, 2015
  4. 2/6 line-log.c: fix a memleakStefan Beller, Mar 31, 2015
  5. 3/6 line-log.c: fix a memleakStefan Beller, Mar 31, 2015
  6. Torsten BögershausenMar 31, 2015
  7. Junio C HamanoMar 31, 2015
  8. Stefan BellerMar 31, 2015
  9. Junio C HamanoMar 31, 2015
  10. 4/6 wt-status.c: fix a memleakStefan Beller, Mar 31, 2015
  11. 5/6 pack-bitmap.c: fix a memleakStefan Beller, Mar 31, 2015
  12. Jeff KingMar 31, 2015
  13. 6/6 entry.c: fix a memleakStefan Beller, Mar 31, 2015
  14. Junio C HamanoMar 31, 2015
  15. John KeepingMar 31, 2015
  16. Junio C HamanoMar 31, 2015

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.