summaryrefslogtreecommitdiff
path: root/include/git2/sys/alloc.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-03-16 10:14:50 +0000
committerPatrick Steinhardt <ps@pks.im>2018-06-07 12:57:39 +0200
commit74b7ddbf333ee20a4b2bc7a0e7c3f7c2aa4fc590 (patch)
treec982f3373dc2f50a361e55798d524f9530c2483c /include/git2/sys/alloc.h
parent9865cd1696ac4a3f47991a9a1d79b17cef5edc89 (diff)
downloadlibgit2-74b7ddbf333ee20a4b2bc7a0e7c3f7c2aa4fc590.tar.gz
settings: allow swapping out memory allocator
Tie in the newly created infrastructure for swapping out memory allocators into our settings code. A user can now simply use the new option "GIT_OPT_SET_ALLOCATOR" with `git_libgit2_opts`, passing in an already initialized allocator structure as vararg.
Diffstat (limited to 'include/git2/sys/alloc.h')
-rw-r--r--include/git2/sys/alloc.h24
1 files changed, 24 insertions, 0 deletions
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