From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4765 invoked by alias); 9 Jun 2003 17:03:52 -0000 Mailing-List: contact sid-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: sid-owner@sources.redhat.com Received: (qmail 4758 invoked from network); 9 Jun 2003 17:03:51 -0000 Received: from unknown (HELO touchme.toronto.redhat.com) (207.219.125.105) by sources.redhat.com with SMTP; 9 Jun 2003 17:03:51 -0000 Received: from redhat.com (vpn50-36.rdu.redhat.com [172.16.50.36]) by touchme.toronto.redhat.com (Postfix) with ESMTP id 51A3280001E; Mon, 9 Jun 2003 13:03:50 -0400 (EDT) Message-ID: <3EE4BE6C.8080401@redhat.com> Date: Mon, 09 Jun 2003 17:03:00 -0000 From: Dave Brolley User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20021216 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Frank Ch. Eigler" Cc: sid@sources.redhat.com Subject: Re: [patch] Add Logging Support for SID Components References: <3ED7CCCB.4070004@redhat.com> <20030601143239.GA31953@redhat.com> <3EE49705.8000802@redhat.com> <20030609144958.GB23478@redhat.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-q2/txt/msg00046.txt.bz2 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