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
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Jun 3, 2013, 15:59 UTC
Message-ID
<51ACBD68.4070506@lsrfire.ath.cx>
In-Reply-To
<CAMP44s2HotyK7hh0nFjCe+BBtu1pyqmkn6=yt9WV6UyhxjrXoQ@mail.gmail.com>
Am 03.06.2013 02:04, schrieb Felipe Contreras:
Show 23 quoted lines
> On Sun, Jun 2, 2013 at 6:47 PM, René Scharfe
> <rene.scharfe@lsrfire.ath.cx> wrote:
>> Am 03.06.2013 01:23, schrieb Felipe Contreras:
>>
>>> I didn't say we should do 'if (ce) free(ce);' instead of 'free(ce);' I
>>> said we should do 'if (cd && ce != o->df_conflict_entry)' instead of
>>> 'if (ce != o->df_conflict_entry)'.
>>
>>
>> I did assume you meant the latter.
>>
>>
>>> There's no reason not to.
>>
>>
>> Only the minor ones already mentioned: More text,
>
> Five characters.
>
>> one more branch in object
>> code,
>
> Which might actually be more optimal.

The difference in absolute numbers will most certainly be within the noise for this one case.

>> no benefit except for some hypothetical future case that's caught by
>> the test suite anyway -- or by code review.
>
> That's not the benefit, the benefit is that the code is clearer.

I don't see that, and I don't like adding a check that I don't expect to be ever needed. Users are safe because the test suite is going to catch a missing check.

In general, I think those who introduce dependencies should add the necessary checks. They have to consider the invariants anyway, no matter how many checks you add beforehand for their convenience.

Show 6 quoted lines
>> I wonder if we already reached the point where we spent more time discussing
>> this change than the time needed by the envisioned developer to find and fix
>> the NULL check that suddenly became necessary. :)
>
> Maybe, but if what you want is to avoid the discussion, you could just
> add the extra five characters and be done with it.

Or you could submit a patch on top that adds the check. I'd send it out if you'd supply a commit message. My review comment would be "mostly harmless, but I don't like it very much because it's not needed now and probably won't ever".

But I'm more interested in a different way forward: Would it make sense to push the allocations (and frees) into the merge functions? Currently they duplicate one of the cache entries. Would the merge functions become too ugly or too big if they'd have to build them themselves, avoiding duplication? Would it be significantly faster?

René
Previous: Felipe ContrerasNext: Felipe Contreras
Message 18 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.