bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vsnprintf unnecessarily configures and builds vasnprintf.o etc.


From: Eric Blake
Subject: Re: vsnprintf unnecessarily configures and builds vasnprintf.o etc.
Date: Fri, 08 Apr 2011 05:31:38 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.9

On 04/08/2011 03:58 AM, Simon Josefsson wrote:
> Paul Eggert <address@hidden> writes:
> 
>> But that raises another problem.  For Emacs, I'd like a variant of
>> vasnprintf that uses Emacs's allocators rather than malloc/realloc/free.
>> I could instead attack the problem by blocking interrupts while
>> calling vasnprintf, but I'd rather not add these extra system calls
>> for every call to vasnprintf.
>>
>> I expect that I can do that by creating a new module (vcasnprintf, say),
>> which defines a function that acts like vasnprintf but allocates
>> storage as specified by a struct allocator parameter.  The best way
>> to do that, I expect, would be to refactor vasnprintf.c, and I am
>> thinking of proposing something along those lines.
> 
> Couldn't you just call the existing *printf functions and reallocate the
> output using Emacs' strdup or similar?  There will be a slight
> performance hit, but I wonder if it matters compared to the cost if
> maintaining *printf functions that differs even more from glibc.

Not really, because even glibc's snprintf calls malloc() internally for
certain cases, even when you pass in a size of 0.  If the whole point of
this exercise is to completely avoid malloc() in favor of a safer
allocater, then you'd have to lock every call to snprintf.

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]