diff options
Diffstat (limited to 'include/git2')
| -rw-r--r-- | include/git2/common.h | 7 | ||||
| -rw-r--r-- | include/git2/sys/alloc.h | 24 |
2 files changed, 31 insertions, 0 deletions
diff --git a/include/git2/common.h b/include/git2/common.h index f65cfdd01..f095e5990 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -183,6 +183,7 @@ typedef enum { GIT_OPT_GET_WINDOWS_SHAREMODE, GIT_OPT_SET_WINDOWS_SHAREMODE, GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, + GIT_OPT_SET_ALLOCATOR } git_libgit2_opt_t; /** @@ -345,6 +346,12 @@ typedef enum { * > additional checksum calculation on each object. This defaults * > to enabled. * + * opts(GIT_OPT_SET_ALLOCATOR, git_allocator *allocator) + * + * > Set the memory allocator to a different memory allocator. This + * > allocator will then be used to make all memory allocations for + * > libgit2 operations. + * * @param option Option key * @param ... value to set the option * @return 0 on success, <0 on failure diff --git a/include/git2/sys/alloc.h b/include/git2/sys/alloc.h index a0955ce8b..4bc5323e2 100644 --- a/include/git2/sys/alloc.h +++ b/include/git2/sys/alloc.h @@ -72,6 +72,30 @@ typedef struct { void (*gfree)(void *ptr); } git_allocator; +/** + * Initialize the allocator structure to use the `stdalloc` pointer. + * + * Set up the structure so that all of its members are using the standard + * "stdalloc" allocator functions. The structure can then be used with + * `git_allocator_setup`. + * + * @param allocator The allocator that is to be initialized. + * @return An error code or 0. + */ +int git_stdalloc_init_allocator(git_allocator *allocator); + +/** + * Initialize the allocator structure to use the `crtdbg` pointer. + * + * Set up the structure so that all of its members are using the "crtdbg" + * allocator functions. Note that this allocator is only available on Windows + * platforms and only if libgit2 is being compiled with "-DMSVC_CRTDBG". + * + * @param allocator The allocator that is to be initialized. + * @return An error code or 0. + */ +int git_win32_crtdbg_init_allocator(git_allocator *allocator); + GIT_END_DECL #endif |
