public inbox for sid@sourceware.org
 help / color / mirror / Atom feed
From: Dave Brolley <brolley@redhat.com>
To: "Frank Ch. Eigler" <fche@redhat.com>
Cc: sid@sources.redhat.com
Subject: Re: [patch] Add Logging Support for SID Components
Date: Mon, 09 Jun 2003 17:03:00 -0000	[thread overview]
Message-ID: <3EE4BE6C.8080401@redhat.com> (raw)
In-Reply-To: <20030609144958.GB23478@redhat.com>



Frank Ch. Eigler wrote:

>The new version seems to have at least one actual problem though:
>the way that the buffer array is managed.  Its allocation/deallocation
>strategy should be consistent (probably "new char[]" and "delete[] char")
>regardless of the availability of the various *sprintf variants.  It should
>probably not even be in #if/#endif markers.  The new code appears to be
>able to hit free() even though malloc() was never called.
>  
>
The piece of information that you're probably missing is that vasprintf 
automatically allocates a buffer of the proper size each time it is 
called and it uses malloc. Thus free () is only called when using 
vasprintf (! HAVE_VSNPRINTF && HAVE_VASPRINTF). Otherwise 
(HAVE_VSNPRINTF || ! HAVE_VAPRINTF) a persistent buffer is used  which 
can be grown if necessary only when vsnprintf is used. I chose to use 
new/delete here since I had a choice.

I have reviewed the code again and believe that it is correct. I can get 
the call to free() out of #if/#endif if I allocate a buffer everytime 
for all alternatives using malloc, but conditional compilation would 
still be necessary for the allocations/growth.

Let me know if you feel these changes are necessary.

Thanks,
Dave


      reply	other threads:[~2003-06-09 17:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-30 21:27 Dave Brolley
2003-05-30 21:44 ` Dave Brolley
2003-06-01 14:32 ` Frank Ch. Eigler
2003-06-01 23:52   ` Ben Elliston
2003-06-02  0:01     ` Dave Brolley
2003-06-09 14:15   ` Dave Brolley
2003-06-09 14:50     ` Frank Ch. Eigler
2003-06-09 17:03       ` Dave Brolley [this message]

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

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

  git send-email \
    --in-reply-to=3EE4BE6C.8080401@redhat.com \
    --to=brolley@redhat.com \
    --cc=fche@redhat.com \
    --cc=sid@sources.redhat.com \
    /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).