Skip to content

Commit 765ff6e

Browse files
committed
allocators: make crtdbg allocator reuse its own realloc
In commit 6e0dfc6 (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 parent 48727e5 commit 765ff6e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/allocators/win32_crtdbg.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ static void *crtdbg__reallocarray(void *ptr, size_t nelem, size_t elsize, const
7676
{
7777
size_t newsize;
7878

79-
return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ?
80-
NULL : _realloc_dbg(ptr, newsize, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
79+
if (GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize))
80+
return NULL;
81+
82+
return crtdbg__realloc(ptr, newsize, file, line);
8183
}
8284

8385
static void *crtdbg__mallocarray(size_t nelem, size_t elsize, const char *file, int line)

0 commit comments

Comments
 (0)