From: David Barksdale Date: Sun, 4 Sep 2016 15:27:58 +0000 (+0000) Subject: I think this is a bit more readable X-Git-Tag: initial-import-from-subversion-38251~296 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=330db1cce63a198b86cf0bcaa9949c20d7681d05;p=oweals%2Fgnunet.git I think this is a bit more readable --- 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); }