From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id AF7351F8C6 for ; Sat, 7 Aug 2021 13:24:32 +0000 (UTC) Received: from localhost ([::1]:43412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCMJS-0001hc-FY for normalperson@yhbt.net; Sat, 07 Aug 2021 09:24:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCMFk-0007S3-4t for bug-gnulib@gnu.org; Sat, 07 Aug 2021 09:20:40 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.160]:13526) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCMFh-0008J0-P3 for bug-gnulib@gnu.org; Sat, 07 Aug 2021 09:20:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1628342427; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=RTvg9xFFQRr6Lc27/siDop4GbAsrS2syAnUwtEp8wcM=; b=TWD1w5BK7DO4pd78xqhqMwZ6flY3a4fmnox7MyOFKavdMhsUpQH5CikT2Wg9WkY83U ebI3C6PiH7TW+Q9rBrHi3nQxbXrZWl0oH4vXLrfqvzIUDGBZnxrXmwy+uz/HampQ52nc jfzFKqdiPgOnehUhhFfjG3X8bUn+BEIJTPLJUJb+jYfARDOoQKFrn3ngMX1sLtYQ9cX1 F139KNVWcz0vc2HNqguJ2B8hL3qH+0TpqdYQly7905TUAlqAwL4tpdmeF6SAmx2X8e/0 Jqeu0rB4FHEppFa3pF1scG0o42hQuM5GA+64hg5dRxmnf84MmVm/hy3e14ukX69rTey+ KaEw== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH/DXj0JGsbh0vbrMZq" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.31.0 DYNA|AUTH) with ESMTPSA id I0a189x77DKRFN8 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sat, 7 Aug 2021 15:20:27 +0200 (CEST) From: Bruno Haible To: bug-gnulib@gnu.org Subject: Re: [PATCH 07/27] malloca: improve -fanalyzer malloc checking Date: Sat, 07 Aug 2021 15:20:27 +0200 Message-ID: <2619022.DqNQGvE0Ip@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <20210802011821.1057057-7-eggert@cs.ucla.edu> References: <20210802011821.1057057-1-eggert@cs.ucla.edu> <20210802011821.1057057-7-eggert@cs.ucla.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=81.169.146.160; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Eggert Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Paul Eggert wrote: > diff --git a/lib/malloca.h b/lib/malloca.h > index 6fa1d8b20..dbbec3f06 100644 > --- a/lib/malloca.h > +++ b/lib/malloca.h > @@ -65,7 +65,6 @@ extern "C" { > # define malloca(N) \ > mmalloca (N) > #endif > -extern void * mmalloca (size_t n); > > /* Free a block of memory allocated through malloca(). */ > #if HAVE_ALLOCA > @@ -74,6 +73,10 @@ extern void freea (void *p); > # define freea free > #endif > > +extern void *mmalloca (size_t n) > + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (freea, 1) > + _GL_ATTRIBUTE_ALLOC_SIZE ((1)); > + > /* nmalloca(N,S) is an overflow-safe variant of malloca (N * S). > It allocates an array of N objects, each with S bytes of memory, > on the stack. N and S should be nonnegative and free of side effects. malloca and mmalloca belong close together. I prefer to move the 'freea' declaration, so that malloca and mmalloca are declared together. 2021-08-07 Bruno Haible malloca: Tweak last commit. * lib/malloca.h: Keep use and declaration of mmalloca close together. diff --git a/lib/malloca.h b/lib/malloca.h index dbbec3f..7eb63d2 100644 --- a/lib/malloca.h +++ b/lib/malloca.h @@ -51,6 +51,13 @@ extern "C" { # define safe_alloca(N) ((void) (N), NULL) #endif +/* Free a block of memory allocated through malloca(). */ +#if HAVE_ALLOCA +extern void freea (void *p); +#else +# define freea free +#endif + /* malloca(N) is a safe variant of alloca(N). It allocates N bytes of memory allocated on the stack, that must be freed using freea() before the function returns. Upon failure, it returns NULL. */ @@ -65,14 +72,6 @@ extern "C" { # define malloca(N) \ mmalloca (N) #endif - -/* Free a block of memory allocated through malloca(). */ -#if HAVE_ALLOCA -extern void freea (void *p); -#else -# define freea free -#endif - extern void *mmalloca (size_t n) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (freea, 1) _GL_ATTRIBUTE_ALLOC_SIZE ((1));