[dev] [dwmstatus] smprintf rewritten (try)

From: Thuban <thuban_AT_singularity.fr>
Date: Sun, 23 Dec 2012 21:51:27 +0100

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

This archive was generated by hypermail 2.3.0 : Sun Dec 23 2012 - 22:00:05 CET