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

Re: [PATCH v2 1/1] xdiff: provide indirection to git functions

From
Edward Thomson <ethomson@edwardthomson.com>
Date
Feb 25, 2022, 18:38 UTC
Message-ID
<20220225183854.GA9@811aa366e12e>
In-Reply-To
<xmqqo82udctt.fsf@gitster.g>
On Fri, Feb 25, 2022 at 10:24:14AM -0800, Junio C Hamano wrote:
> 
> Not so fast.  I still do not see a strong reason to support
> xdl_malloc() and other wrappers.

git has an `xmalloc` but no matching `xfree`. libgit2 does not necessarily use the system allocator (and on Windows, you run into the question of _which_ system allocator you're using) and therefore has its own allocation _and_ deallocation functions.

When libgit2 includes xdiff, I don't want to monkey around and try to redefine `free` to our deallocator.

There are several options that could suffice for this. A different tactic is to have xdiff call `xfree` which is just defined as `free` in git. This would feel non-obvious to me as a git developer that in this one part of the project, I need to use `xfree` instead of `free` on memory that I have `xmalloc`ed. Using a net new name for allocation functions may help serve as a reminder that it is a different API.

Show 6 quoted lines
> Is the expectation for other projects when using the unified code,
> they do not use xdiff/git-xdiff.h and instead add
> xdiff/frotz-xdiff.h that defines xdl_malloc() and friends with the
> infrastructure they provide as part of the Frotz project (and the
> Xyzzy project would do the same with xdiff/xyzzy-xdiff.h header for
> them), making "git" the first among equal other consumers?

No, the thinking is that they would provide their own `git-xdiff.h` that defines the mappings to their project-specific APIs.

Cheers- -ed

Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 8 in “xdiff: provide indirection to git functions”
  1. 0/1 xdiff: provide indirection to git functionsEdward Thomson, Feb 17, 2022
  2. 1/1 xdiff: provide indirection to git functionsEdward Thomson, Feb 17, 2022
  3. Phillip WoodFeb 22, 2022
  4. Johannes SchindelinFeb 25, 2022
  5. Junio C HamanoFeb 25, 2022
  6. Edward ThomsonFeb 25, 2022
  7. Junio C HamanoFeb 25, 2022
  8. Junio C HamanoFeb 25, 2022

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.