1. 14 May, 2023 1 commit
    • alloc: simplify pluggable allocators · 9dd1bfe8
      Remove the number of functions that custom allocator users need to
      provide; nobody should need to implement `substrdup`. Keep it to the
      basics that are actually _needed_ for allocation (malloc, realloc,
      free) and reimplement the rest ourselves.
      
      In addition, move the failure check and error setting _out_ of the
      custom allocators and into a wrapper so that users don't need to deal
      with this. This also allows us to call our allocator (without the
      wrapper) early so that it does not try to set an error on failure, which
      may be important for bootstrapping.
      Edward Thomson committed
  2. 23 Feb, 2022 2 commits
  3. 09 Dec, 2020 1 commit
    • alloc: set up an allocator that fails before library init · 08f28ff5
      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.)
      Edward Thomson committed