On Mon, Sep 07, 2009 at 04:36:53PM +0200, Josselin Mouette wrote: > Le lundi 07 septembre 2009 à 13:40 +0200, Bernhard R. Link a écrit : > > For the record: Noone sane would replace g_strdup_printf with snprintf, > > but with asprintf. > Case 1: > char *foo; > if (asprintf(&foo, "%s equals %i", somestring, someint) < 0) { > fprintf(stderr, "Failed to allocate memory"); > abort(); > } > Case 2: > char *foo = g_strdup_printf ("%s equals %i", somestring, > someint); > Pick your choice. Case 1, please. Either case 2 fails to handle the allocation error, or glib is doing its own abort. Neither is acceptable. -- Steve Langasek Give me a lever long enough and a Free OS Debian Developer to set it on, and I can move the world. Ubuntu Developer http://www.debian.org/ slangasek@ubuntu.com vorlon@debian.org
Attachment:
signature.asc
Description: Digital signature