Commit 496b0df2 by Patrick Steinhardt

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.
parent aab8f87b
......@@ -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)))
......
......@@ -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
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment