Hello,
I tried to rewrite smprintf to use asprintf, following your advices.
Can you check if there is anything wrong?
I have some doubt about the necessaries free(). Is it alright if free()
is use outside the function?
The code :
char *
smprintf(char *fmt, ...)
{
va_list fmtargs;
char *buf = NULL;
va_start(fmtargs, fmt);
if (vasprintf(&buf, fmt, fmtargs) == -1){
fprintf(stderr, "malloc vasprintf\n");
exit(1);
}
va_end(fmtargs);
return buf;
}
--
,--. Xavier Cartron
: /` ) M2 MEFPC
| `-' Debian user
\_ jabber : thuban_AT_jabber.fr
Received on Sun Dec 23 2012 - 21:51:27 CET