> Date: Fri, 19 Dec 2008 21:14:37 +0100 > From: Roland Mainz <roland.mainz at nrubsig.org> > Subject: Re: PSARC/2008/778 - asprintf, vasprintf > To: "Roger A. Faulkner" <Roger.Faulkner at sun.com> > Cc: psarc-ext at sac.sfbay.sun.com, daniel.price at sun.com, peter.memishian > at sun.com > X-Brightmail-Tracker: AAAAAA== > X-Virus-Scanned: ClamAV 0.94.1/8786/Fri Dec 19 11:30:31 2008 on mail-in-02.arcor-online.net > X-Virus-Status: Clean > X-Antispam: No, score=0.0/5.0, scanned in 0.058sec at (localhost [127.0.0.1]) by smf-spamd v1.3.1 - http://smfs.sf.net/ > > "Roger A. Faulkner" wrote: > > > > I am sponsoring this automatic case for myself. > > > > 1. Introduction > > > > This case adds two new functions to the C library, asprintf() > > and vasprintf() as follows: > > > > int asprintf(char **ret, const char *format, ...); > > int vasprintf(char **ret, const char *format, va_list ap); > > > > The committment level of these interfaces is Committed. > > > > The release binding is "patch" > > (so it can be back-ported to Solaris 10 if required). > > > > 2. Discussion > > > > Linux and the various BSD operating systems provide the *asprintf() > > family of functions. These behave as sprintf(), except that they > > allocate a string large enough to hold the result, and return a > > pointer to that string. The caller is later expected to free() > > this buffer. > > Will this even work if another library is used for |malloc()|&&|free()| > calls (IMO it should work but I am not sure about the case when an > application is linked via -B direct) ?
Sure. The code for [v]asprintf() calls malloc() (and free() on error). libc in general makes sure that any preloaded malloc library is used instead of the version in libc itself. It's no different from any other call to malloc() internally to libc. (The libc mapfiles mark malloc and free as NODIRECT.) Roger
