Commit 765ff6e029a422d910ec65c38fd16ed90caff7b5

Patrick Steinhardt 2019-02-21T12:35:48

allocators: make crtdbg allocator reuse its own realloc In commit 6e0dfc6ff (Make stdalloc__reallocarray call stdalloc__realloc, 2019-02-16), we have changed the stdalloc allocator to reuse `stdalloc__realloc` to implement `stdalloc__reallocarray`. This commit is making the same change for the Windows-specific crtdbg allocator to avoid code duplication.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/allocators/win32_crtdbg.c b/src/allocators/win32_crtdbg.c
index d1539d5..1187e2f 100644
--- a/src/allocators/win32_crtdbg.c
+++ b/src/allocators/win32_crtdbg.c
@@ -76,8 +76,10 @@ static void *crtdbg__reallocarray(void *ptr, size_t nelem, size_t elsize, const 
 {
 	size_t newsize;
 
-	return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ?
-		NULL : _realloc_dbg(ptr, newsize, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
+	if (GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize))
+		return NULL;
+
+	return crtdbg__realloc(ptr, newsize, file, line);
 }
 
 static void *crtdbg__mallocarray(size_t nelem, size_t elsize, const char *file, int line)