gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37875 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r37875 - gnunet/src/util
Date: Sun, 4 Sep 2016 17:27:58 +0200

Author: amatus
Date: 2016-09-04 17:27:58 +0200 (Sun, 04 Sep 2016)
New Revision: 37875

Modified:
   gnunet/src/util/common_allocation.c
Log:
I think this is a bit more readable




Modified: gnunet/src/util/common_allocation.c
===================================================================
--- gnunet/src/util/common_allocation.c 2016-09-04 15:26:10 UTC (rev 37874)
+++ gnunet/src/util/common_allocation.c 2016-09-04 15:27:58 UTC (rev 37875)
@@ -351,7 +351,7 @@
 GNUNET_xgrow_ (void **old,
               size_t elementSize,
               unsigned int *oldCount,
-               unsigned int newCount,
+         unsigned int newCount,
               const char *filename,
               int linenumber)
 {
@@ -360,7 +360,7 @@
 
   GNUNET_assert_at (INT_MAX / elementSize > newCount, filename, linenumber);
   size = newCount * elementSize;
-  if (size == 0)
+  if (0 == size)
   {
     tmp = NULL;
   }
@@ -367,13 +367,13 @@
   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);
   }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]