Rich Cook <[EMAIL PROTECTED]> writes: > On Jul 5, 2007, at 11:08 AM, Hrvoje Niksic wrote: > >> Rich Cook <[EMAIL PROTECTED]> writes: >> >>> Trouble is, it's undocumented as to how to free the resulting >>> string. Do I call free on it? >> >> Yes. "Freshly allocated with malloc" in the function documentation >> was supposed to indicate how to free the string. > > Oh, I looked in the source and there was this xmalloc thing that > didn't show up in my man pages, so I punted. Sorry.
No problem. Note that xmalloc isn't entirely specific to Wget, it's a fairly standard GNU name for a malloc-or-die function. Now I remembered that Wget also has xfree, so the above advice is not entirely correct -- you should call xfree instead. However, in the normal case xfree is a simple wrapper around free, so even if you used free, it would have worked just as well. (The point of xfree is that if you compile with DEBUG_MALLOC, you get a version that check for leaks, although it should be removed now that there is valgrind, which does the same job much better. There is also the business of barfing on NULL pointers, which should also be removed.) I'd have implemented a portable asprintf, but I liked the aprintf interface better (I first saw it in libcurl).
