summaryrefslogtreecommitdiff
path: root/src/allocators
Commit message (Collapse)AuthorAgeFilesLines
* Update src/allocators/stdalloc.cEdward Thomson2021-07-201-1/+1
| | | Co-authored-by: lhchavez <lhchavez@lhchavez.com>
* alloc: add GIT_DEBUG_STRICT_ALLOCEdward Thomson2021-07-191-10/+41
| | | | | | | | | | | Add `GIT_DEBUG_STRICT_ALLOC` to help identify problematic callers of allocation code that pass a `0` size to the allocators and then expect a non-`NULL` return. When given a 0-size allocation, `malloc` _may_ return either a `NULL` _or_ a pointer that is not writeable. Most systems return a non-`NULL` pointer; AIX is an outlier. We should be able to cope with this AIXy behavior, so this adds an option to emulate it.
* alloc: set up an allocator that fails before library initEdward Thomson2020-12-092-0/+115
| | | | | | | | | | | | | | | | | | | We require the library to be initialized with git_libgit2_init before it is functional. However, if a user tries to uses the library without doing so - as they might when getting started with the library for the first time - we will likely crash. This commit introduces some guard rails - now instead of having _no_ allocator by default, we'll have an allocator that always fails, and never tries to set an error message (since the thread-local state is set up by git_libgit2_init). We've modified the error retrieval function to (try to) ensure that the library has been initialized before getting the thread-local error message. (Unfortunately, we cannot determine if the thread local storage has actually been configured, this does require initialization by git_libgit2_init. But a naive attempt should be good enough for most cases.)
* cmake: rename MSVC_CRTDBG to WIN32_LEAKCHECKEdward Thomson2020-11-211-1/+1
|
* alloc: rename the win32 leakcheck allocatorEdward Thomson2020-11-213-121/+121
| | | | | The win32 leakchecking system is now named win32_leakcheck. Update the allocator to match.
* win32: "crtdbg" is now "leakcheck"Edward Thomson2020-11-211-6/+5
| | | | | msvc crtdbg is a mouthfull that is not particularly indicative of what it does. Let's rename it to "win32 leakcheck".
* win32: teach the allocator to deal with crtdbgEdward Thomson2020-10-111-0/+1
| | | | | Move the MSVC C runtime debugging bits into the allocator's global init function.
* allocators: make crtdbg allocator reuse its own reallocPatrick Steinhardt2019-02-211-2/+4
| | | | | | | | | In commit 6e0dfc6ff (Make stdalloc__reallocarray call stdalloc__realloc, 2019-02-16), we have changed the stdalloc allocator to reuse `stdalloc__realloc` to implement `stdalloc__reallocarray`. This commit is making the same change for the Windows-specific crtdbg allocator to avoid code duplication.
* allocators: extract crtdbg allocator into its own filePatrick Steinhardt2019-02-212-0/+133
| | | | | | | | | | | | | | | The Windows-specific crtdbg allocator is currently mixed into the crtdbg stacktracing compilation unit, making it harder to find than necessary. Extract it and move it into the new "allocators/" subdirectory to improve discoverability. This change means that the crtdbg compilation unit is now compiled unconditionally, whereas it has previously only been compiled on Windows platforms. Thus we now have additional guards around the code so that it will only be compiled if GIT_MSVC_CRTDBG is defined. This also allows us to move over the fallback-implementation of `git_win32_crtdbg_init_allocator` into the same compilation unit.
* allocators: move standard allocator into subdirectoryPatrick Steinhardt2019-02-212-0/+136
Right now, our two allocator implementations are scattered around the tree in "stdalloc.h" and "win32/w32_crtdbg_stacktrace.h". Start grouping them together in a single directory "allocators/", similar to how e.g. our streams are organized.