From patchwork Fri Jun 13 15:41:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 1494 Received: (qmail 13747 invoked by alias); 13 Jun 2014 15:41:54 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 13733 invoked by uid 89); 13 Jun 2014 15:41:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f181.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=cfnnY3prjki2pVdF7N9qiy9bpAiMqPpIxYOZUf7YGsc=; b=ON2J4T/bz36SE/qaO0tCvzi1FMHFNxzuc1fUrEdoHkGl0nTREFFAe04M0d6HwU/wuf NIhOASCMob58dhIA/c+A6WBOdqYJvkbE0c6IasopZ4O5HfYWAehbQtylN69aHc/w4jzW USa1mIAfsMMQkr+VcZ6YdHbLel4x2L06xs41eoLQAFF5AZbj69GW18k8Aa59gi10yFdQ 9DrtxoLlWPgt0gDb8IWthnweA1fQX73JOHv8s0T8+GRKlk8izvf96dGe0k8MhKYHN/ic AX7vKt45b1ju+8U1+603gnAWccVjCymHfdOInC/PwKOWqUvCan0qk2LBlKwljZAkv4Ry PD5w== X-Gm-Message-State: ALoCoQkp8ikuMRaPPKx49o6sBu7VXDt7ezPVf0kNWVYlvkx686/tlK/ZHC2h+X0WAzuqEGhSeOr5 X-Received: by 10.194.176.1 with SMTP id ce1mr5406387wjc.79.1402674109612; Fri, 13 Jun 2014 08:41:49 -0700 (PDT) From: Will Newton To: libc-alpha@sourceware.org Subject: [PATCH] malloc/malloc.c: Avoid calling sbrk unnecessarily with zero Date: Fri, 13 Jun 2014 16:41:44 +0100 Message-Id: <1402674104-13759-1-git-send-email-will.newton@linaro.org> 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-13 Will Newton * malloc/malloc.c (systrim): If extra is zero then return early. --- malloc/malloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/malloc/malloc.c b/malloc/malloc.c index d8fd8b4..41fd76a 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -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.