Commit 6e0dfc6f by lhchavez

Make stdalloc__reallocarray call stdalloc__realloc

This change avoids calling realloc(3) in more than one place.
parent bda08397
...@@ -88,11 +88,10 @@ static void *stdalloc__reallocarray(void *ptr, size_t nelem, size_t elsize, cons ...@@ -88,11 +88,10 @@ static void *stdalloc__reallocarray(void *ptr, size_t nelem, size_t elsize, cons
{ {
size_t newsize; size_t newsize;
GIT_UNUSED(file); if (GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize))
GIT_UNUSED(line); return NULL;
return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ? return stdalloc__realloc(ptr, newsize, file, line);
NULL : realloc(ptr, newsize);
} }
static void *stdalloc__mallocarray(size_t nelem, size_t elsize, const char *file, int line) static void *stdalloc__mallocarray(size_t nelem, size_t elsize, const char *file, int line)
......
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