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

Re: [PATCH v2 7/7] unpack-trees: free cache_entry array members for merges

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 3, 2013, 20:53 UTC
Message-ID
<CAMP44s2b7gNkiVddN8XVm_u4e4WkxWmvS0mB8XLRv-1tn2Qc9g@mail.gmail.com>
In-Reply-To
<7va9n7gkjq.fsf@alter.siamese.dyndns.org>
On Mon, Jun 3, 2013 at 12:40 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>>> I don't see that, and I don't like adding a check that I don't expect to be
>>> ever needed.
>>
>> It's called self-documenting code; by adding a check for the NULL
>> pointer, we are stating that ce can be NULL, if we don't do that,
>> people reading that code would need to figure that out themselves.
>
> People following the codepath to unpack_nondirectories() already
> have seen enough to know what src[] means and very well know what
> NULL in it means.  The only people possibly confused are those who
> do not know free(NULL) is safe, isn't it?

Wrong. I still do not know what src[] means, and I don't need to know, I can see from the code that the cached entries there leak.

> Honestly speaking, I do not want such people to be touching this
> part of the system.
So we should make it more obfuscated?
-- 
Felipe Contreras
Previous: Junio C Hamano
Message 22 of 22 in “unpack-trees: plug memory leak for merges”
  1. 0/7 unpack-trees: plug memory leak for mergesRené Scharfe, Jun 2, 2013
  2. 1/7 cache: mark cache_entry pointers constRené Scharfe, Jun 2, 2013
  3. 2/7 read-cache: mark cache_entry pointers constRené Scharfe, Jun 2, 2013
  4. 3/7 unpack-trees: factor out dup_entryRené Scharfe, Jun 2, 2013
  5. 4/7 unpack-trees: create working copy of merge entry in merged_entryRené Scharfe, Jun 2, 2013
  6. 5/7 diff-lib, read-tree, unpack-trees: mark cache_entry pointers constRené Scharfe, Jun 2, 2013
  7. 6/7 diff-lib, read-tree, unpack-trees: mark cache_entry array paramters constRené Scharfe, Jun 2, 2013
  8. 7/7 unpack-trees: free cache_entry array members for mergesRené Scharfe, Jun 2, 2013
  9. Felipe ContrerasJun 2, 2013
  10. René ScharfeJun 2, 2013
  11. Felipe ContrerasJun 2, 2013
  12. René ScharfeJun 2, 2013
  13. Felipe ContrerasJun 2, 2013
  14. René ScharfeJun 2, 2013
  15. Felipe ContrerasJun 2, 2013
  16. René ScharfeJun 2, 2013
  17. Felipe ContrerasJun 3, 2013
  18. René ScharfeJun 3, 2013
  19. Felipe ContrerasJun 3, 2013
  20. 8/7 unpack-trees: document that pointer ce can be NULLRené Scharfe, Jun 3, 2013
  21. Junio C HamanoJun 3, 2013
  22. Felipe ContrerasJun 3, 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.