Re: [PATCH v2 05/13] reftable: utility functions
From: Jonathan Nieder <hidden>
Date: 2020-10-12 17:45:12
Patrick Steinhardt wrote:
In order to be as thorough as possible, we thus also need to replace
these function pointers for libgit2's dependencies. As registration of
the allocator happens at runtime, we need to also be able to replace
function pointers of dependencies at runtime. E.g. for OpenSSL, it
provides an API `CRYPTO_set_mem_functions(malloc, realloc, free)` which
we call on global initialization of the libgit2 library.
So, to answer your questions:
- The allocator is global and cannot be changed after initialization
of libgit2.
- It is pluggable, users can set up their own allocators by filling
a structure with function pointers for `free`, `malloc`, `realloc`
etc.
- Due to the pluggable nature, we need to be able to set up those
pointers at runtime. We can provide a set of static wrappers
though which then call into the pluggable functions, so defines
would probably work for us, too.
I hope that answers all of your questions.Thanks! Yes, that's very helpful. Jonathan