unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Siddhesh Poyarekar via Libc-alpha <libc-alpha@sourceware.org>
To: libc-alpha@sourceware.org
Subject: [PING][PATCH] mtrace: Use a static buffer for printing [BZ #25947]
Date: Wed, 11 Aug 2021 13:11:44 +0530	[thread overview]
Message-ID: <1f82d350-b81d-9b72-4456-3c495d516572@sourceware.org> (raw)
In-Reply-To: <20210722132430.1945153-1-siddhesh@sourceware.org>

Ping!

On 7/22/21 6:54 PM, Siddhesh Poyarekar via Libc-alpha wrote:
> Use a static buffer for mtrace printing now that it no longer adds to
> default libc footprint.
> ---
>   malloc/mtrace-impl.c | 14 +++-----------
>   1 file changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/malloc/mtrace-impl.c b/malloc/mtrace-impl.c
> index 0e10ab7f60..83008ca18f 100644
> --- a/malloc/mtrace-impl.c
> +++ b/malloc/mtrace-impl.c
> @@ -34,11 +34,8 @@
>   
>   #include <kernel-features.h>
>   
> -#define TRACE_BUFFER_SIZE 512
> -
>   static FILE *mallstream;
>   static const char mallenv[] = "MALLOC_TRACE";
> -static char *malloc_trace_buffer;
>   
>   static void
>   tr_where (const void *caller, Dl_info *info)
> @@ -184,16 +181,13 @@ do_mtrace (void)
>     mallfile = secure_getenv (mallenv);
>     if (mallfile != NULL)
>       {
> -      char *mtb = malloc (TRACE_BUFFER_SIZE);
> -      if (mtb == NULL)
> -        return;
> -
>         mallstream = fopen (mallfile != NULL ? mallfile : "/dev/null", "wce");
>         if (mallstream != NULL)
>           {
>             /* Be sure it doesn't malloc its buffer!  */
> -          malloc_trace_buffer = mtb;
> -          setvbuf (mallstream, malloc_trace_buffer, _IOFBF, TRACE_BUFFER_SIZE);
> +	  static char tracebuf [512];
> +
> +	  setvbuf (mallstream, tracebuf, _IOFBF, sizeof (tracebuf));
>             fprintf (mallstream, "= Start\n");
>             if (!added_atexit_handler)
>               {
> @@ -203,8 +197,6 @@ do_mtrace (void)
>               }
>   	  __malloc_debug_enable (MALLOC_MTRACE_HOOK);
>           }
> -      else
> -        free (mtb);
>       }
>   }
>   
> 


  reply	other threads:[~2021-08-11  7:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-22 13:24 [PATCH] mtrace: Use a static buffer for printing [BZ #25947] Siddhesh Poyarekar via Libc-alpha
2021-08-11  7:41 ` Siddhesh Poyarekar via Libc-alpha [this message]
2021-08-11 16:55 ` DJ Delorie via Libc-alpha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1f82d350-b81d-9b72-4456-3c495d516572@sourceware.org \
    --to=libc-alpha@sourceware.org \
    --cc=siddhesh@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).