From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A1EBB3858D3C for ; Thu, 1 Sep 2022 18:44:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A1EBB3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662057875; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6YOyNq015KDXBorrIRGekoTPUYaVsPLg2Es9XA/Q+Mg=; b=K66grijXF8afkxOy++3zudwEmBt6cBL2T1XLUCGL+K81KGuIGj+ouVyoB4v/j051G/8gy0 BIDyAYbQvZZvMWOX3Ha1m908DP0enE9ZGbJptk7LvbmMz+6BJp+c/d6nrLCC9z35j9MqKP 0oI78LeBoakb2w4j4opNaIqCigqSUbY= Received: from mail-yb1-f199.google.com (mail-yb1-f199.google.com [209.85.219.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-171-uUraGoYhMUKPUkuQ3cvWag-1; Thu, 01 Sep 2022 14:44:33 -0400 X-MC-Unique: uUraGoYhMUKPUkuQ3cvWag-1 Received: by mail-yb1-f199.google.com with SMTP id i6-20020a259786000000b0069648392979so2938ybo.11 for ; Thu, 01 Sep 2022 11:44:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=6YOyNq015KDXBorrIRGekoTPUYaVsPLg2Es9XA/Q+Mg=; b=oWNILaeyABAfcYr+F7MwOYJs92aoD/54FbCEIaWLuMKiSjtCiLEHe0vrwzk1RNmpev f5UUNyw6SktoCdw6J/7Fv2m3ldtKtW5ec+jzJcKG6ygWSlO+2LDHsQIrAh8lQw4F5W3s Itf+OURG0RhzPChfcUgTif6WmQhNqQ1ghkEDmofm09FG0VdcEb/SueT0NvjNmV4ObpJl VrCdDKlYd/nB/sotBNi78xDrYqA22GfPZ3RhHwNT24QqbTR3OWmyecLYsLUnY77pUpGT d2F8yYnsanlu7kbR4Fgug7hWy3hDVfHh5HB8vf7mP6ufyjbFbmiWmI2vq13fvWW6dKbU ALrA== X-Gm-Message-State: ACgBeo0eRaNCp4NniLdZJzym9F9/2iE/5NjveM2t0fPTsvyJ7XkH2A82 l2tLQhakLJ70SqPlXwyJZd5PNlO0xlDBD37/GRX5e+F6oHlOKkGwdruzTmknHrSdsnd9WOp/l5s kuemYcohglx8ICrQXtDEarWqxSJreurI= X-Received: by 2002:a81:7255:0:b0:33d:d0ce:d8ce with SMTP id n82-20020a817255000000b0033dd0ced8cemr23884415ywc.239.1662057873212; Thu, 01 Sep 2022 11:44:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Tc+cq1MFozUenUJPVHsytoVnpY07aqxQZvuV8wDtH01SW0x9p8/olUPjDSSL9J0ct8ezgkOveTpkWZOwUyUo= X-Received: by 2002:a81:7255:0:b0:33d:d0ce:d8ce with SMTP id n82-20020a817255000000b0033dd0ced8cemr23884402ywc.239.1662057872993; Thu, 01 Sep 2022 11:44:32 -0700 (PDT) MIME-Version: 1.0 References: <20220830135625.2247198-1-torbjorn.svensson@foss.st.com> <20220830135625.2247198-2-torbjorn.svensson@foss.st.com> In-Reply-To: <20220830135625.2247198-2-torbjorn.svensson@foss.st.com> From: Jeff Johnston Date: Thu, 1 Sep 2022 14:44:22 -0400 Message-ID: Subject: Re: [PATCH 2/2] Don't allocate another header when merging chunks To: =?UTF-8?Q?Torbj=C3=B6rn_SVENSSON?= Cc: Newlib X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Sep 2022 18:44:37 -0000 I think that the check for MALLOC_MINCHUNK should still apply. Do you agree? -- Jeff J. On Tue, Aug 30, 2022 at 9:57 AM Torbj=C3=B6rn SVENSSON < torbjorn.svensson@foss.st.com> wrote: > In the nano version of malloc, when the last chunk is to be extended, > there is no need to acount for the header again as it's already taken > into account in the overall "alloc_size" at the beginning of the > function. > > Contributed by STMicroelectronics > > Signed-off-by: Torbj=C3=B6rn SVENSSON > --- > newlib/libc/stdlib/nano-mallocr.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/newlib/libc/stdlib/nano-mallocr.c > b/newlib/libc/stdlib/nano-mallocr.c > index 43eb20e07..b2273ba60 100644 > --- a/newlib/libc/stdlib/nano-mallocr.c > +++ b/newlib/libc/stdlib/nano-mallocr.c > @@ -328,10 +328,6 @@ void * nano_malloc(RARG malloc_size_t s) > /* The last free item has the heap end as neighbour. > * Let's ask for a smaller amount and merge */ > alloc_size -=3D p->size; > - alloc_size =3D ALIGN_SIZE(alloc_size, CHUNK_ALIGN); /* si= ze > of aligned data load */ > - alloc_size +=3D MALLOC_PADDING; /* padding */ > - alloc_size +=3D CHUNK_OFFSET; /* size of chunk head */ > - alloc_size =3D MAX(alloc_size, MALLOC_MINCHUNK); > > if (sbrk_aligned(RCALL alloc_size) !=3D (void *)-1) > { > -- > 2.25.1 > >