From 330db1cce63a198b86cf0bcaa9949c20d7681d05 Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Sun, 4 Sep 2016 15:27:58 +0000 Subject: [PATCH] I think this is a bit more readable --- src/util/common_allocation.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index 91d0a600a..71dd46bf1 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c @@ -351,7 +351,7 @@ void GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount, - unsigned int newCount, + unsigned int newCount, const char *filename, int linenumber) { @@ -360,20 +360,20 @@ GNUNET_xgrow_ (void **old, GNUNET_assert_at (INT_MAX / elementSize > newCount, filename, linenumber); size = newCount * elementSize; - if (size == 0) + if (0 == size) { tmp = NULL; } else { tmp = GNUNET_xmalloc_ (size, filename, linenumber); - if (*oldCount > newCount) - *oldCount = newCount; /* shrink is also allowed! */ if (NULL != *old) - GNUNET_memcpy (tmp, *old, elementSize * (*oldCount)); + { + GNUNET_memcpy (tmp, *old, elementSize * GNUNET_MIN(*oldCount, newCount)); + } } - if (*old != NULL) + if (NULL != *old) { GNUNET_xfree_ (*old, filename, linenumber); } -- 2.25.1