grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Introduce xasprintf


From: Colin Watson
Subject: Re: [PATCH] Introduce xasprintf
Date: Mon, 7 Dec 2009 16:48:24 +0000
User-agent: Mutt/1.5.18 (2008-05-17)

On Fri, Sep 04, 2009 at 06:47:17PM +0200, Neal H. Walfield wrote:
> At Wed, 2 Sep 2009 02:49:39 +0100,
> Colin Watson wrote:
> > +#ifndef HAVE_VASPRINTF
> > +
> > +int
> > +vasprintf (char **buf, const char *fmt, va_list ap)
> > +{
> > +  /* Should be large enough.  */
> > +  *buf = xmalloc (512);
> > +
> > +  return vsprintf (*buf, fmt, ap);
> > +}
> > +
> > +#endif
> 
> Perhaps check that the number of characters is not more than 512 (if
> so, panic).

I agree it's suboptimal, but I'm not sure this is possible without
shipping our own vsprintf implementation, which I would like to avoid
(gnulib does this properly, but it's much larger). Still, note that my
patch didn't really add that xmalloc code - all I did was move it from
the asprintf implementation - so this can be dealt with in a further
change if we choose.

I've gone ahead and committed this, since it's now well past 1.97 and I
think this is a clear improvement.

Thanks,

-- 
Colin Watson                                       address@hidden




reply via email to

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