Am 09.04.2011 11:28, schrieb Ilmari Karonen:
char *vasprintf (const char *format, va_list ap) { int len; char *buf; len = vsnprintf(NULL, 0, format, ap); /* get needed size */ if (len< 0) return NULL; buf = malloc(len + 1); /* reserve 1 byte for trailing \0 */ if (!len) return NULL;
shouldn't that line read if (!buf) return NULL;
if (vsnprintf(buf, len + 1, format, ap) == len) return buf; free(buf); /* something went wrong in second vsnprintf() */ return NULL; }
Peter