malloc/malloc.c: Avoid calling sbrk unnecessarily with zero
authorWill Newton <will.newton@linaro.org>
Fri, 13 Jun 2014 15:37:12 +0000 (16:37 +0100)
committerWill Newton <will.newton@linaro.org>
Thu, 19 Jun 2014 13:34:08 +0000 (14:34 +0100)
Due to my bad review suggestion for the fix for BZ #15089 a check
was removed from systrim to prevent sbrk being called with a zero
argument. Add the check back to avoid this useless work.

ChangeLog:

2014-06-19  Will Newton  <will.newton@linaro.org>

* malloc/malloc.c (systrim): If extra is zero then return
early.

ChangeLog
malloc/malloc.c

index 2a11522..ea0c48f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-19  Will Newton  <will.newton@linaro.org>
+
+       * malloc/malloc.c (systrim): If extra is zero then return
+       early.
+
 2014-06-19  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
        * benchtests/Makefile ($(objpfx)bench-%.c): Remove $(.).
index d8fd8b4..41fd76a 100644 (file)
@@ -2749,6 +2749,9 @@ systrim (size_t pad, mstate av)
   /* Release in pagesize units, keeping at least one page */
   extra = (top_area - pad) & ~(pagesz - 1);
 
+  if (extra == 0)
+    return 0;
+
   /*
      Only proceed if end of memory is where we last set it.
      This avoids problems if there were foreign sbrk calls.