summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-03-14 10:28:50 +0000
committerPatrick Steinhardt <ps@pks.im>2018-06-07 12:57:39 +0200
commit496b0df2ca2a115d2e5a7099f2b8fd6d7409fcb2 (patch)
treef4e393c81d191f9805d2d43926812b5e947016aa /src
parentaab8f87bbab3def110c7cb43961f5b1fb5c5b642 (diff)
downloadlibgit2-496b0df2ca2a115d2e5a7099f2b8fd6d7409fcb2.tar.gz
win32: crtdbg: provide independent `free` function
Currently, the `git__free` function is being defined in a single place, only, disregarding whether we use our standard allocators or the crtdbg allocators. This makes it a bit harder to convert our code base to use pluggable allocators, and furthermore makes the border between our two allocators a bit more blurry. Implement a separate `git__crtdbg__free` function for the crtdbg allocator in order to completely separate both allocator implementations.
Diffstat (limited to 'src')
-rw-r--r--src/util.h5
-rw-r--r--src/win32/w32_crtdbg_stacktrace.c6
-rw-r--r--src/win32/w32_crtdbg_stacktrace.h1
3 files changed, 10 insertions, 2 deletions
diff --git a/src/util.h b/src/util.h
index 67ae4ef70..5b1354cad 100644
--- a/src/util.h
+++ b/src/util.h
@@ -79,6 +79,7 @@
#define git__realloc(ptr, size) git__crtdbg__realloc(ptr, size, __FILE__, __LINE__)
#define git__reallocarray(ptr, nelem, elsize) git__crtdbg__reallocarray(ptr, nelem, elsize, __FILE__, __LINE__)
#define git__mallocarray(nelem, elsize) git__crtdbg__mallocarray(nelem, elsize, __FILE__, __LINE__)
+#define git__free git__crtdbg__free
#else
@@ -169,13 +170,13 @@ GIT_INLINE(void *) git__mallocarray(size_t nelem, size_t elsize)
return git__reallocarray(NULL, nelem, elsize);
}
-#endif /* !MSVC_CTRDBG */
-
GIT_INLINE(void) git__free(void *ptr)
{
free(ptr);
}
+#endif /* !MSVC_CTRDBG */
+
#define STRCMP_CASESELECT(IGNORE_CASE, STR1, STR2) \
((IGNORE_CASE) ? strcasecmp((STR1), (STR2)) : strcmp((STR1), (STR2)))
diff --git a/src/win32/w32_crtdbg_stacktrace.c b/src/win32/w32_crtdbg_stacktrace.c
index e26766a51..6164fedfc 100644
--- a/src/win32/w32_crtdbg_stacktrace.c
+++ b/src/win32/w32_crtdbg_stacktrace.c
@@ -145,6 +145,11 @@ void *git__crtdbg__mallocarray(size_t nelem, size_t elsize, const char *file, in
return git__crtdbg__reallocarray(NULL, nelem, elsize, file, line);
}
+void git__crtdbg__free(void *ptr)
+{
+ free(ptr);
+}
+
/**
* Compare function for bsearch on g_cs_index table.
*/
@@ -415,4 +420,5 @@ const char *git_win32__crtdbg_stacktrace(int skip, const char *file)
return result;
}
+
#endif
diff --git a/src/win32/w32_crtdbg_stacktrace.h b/src/win32/w32_crtdbg_stacktrace.h
index 5527d6c03..f70891ae7 100644
--- a/src/win32/w32_crtdbg_stacktrace.h
+++ b/src/win32/w32_crtdbg_stacktrace.h
@@ -105,6 +105,7 @@ char *git__crtdbg__substrdup(const char *start, size_t n, const char *file, int
void *git__crtdbg__realloc(void *ptr, size_t size, const char *file, int line);
void *git__crtdbg__reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line);
void *git__crtdbg__mallocarray(size_t nelem, size_t elsize, const char *file, int line);
+void *git__crtdbg__free(void *ptr);
#endif
#endif