From: Niels Provos Date: Fri, 11 Jun 2004 04:42:56 +0000 (+0000) Subject: make it compile on systems without vasprintf X-Git-Tag: release-1.1b~62 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de5fc61928cd202ef35c860039ab16000b89fd5b;p=libevent make it compile on systems without vasprintf svn:r107 --- diff --git a/buffer.c b/buffer.c index bbd9378f..afdcb1d2 100644 --- a/buffer.c +++ b/buffer.c @@ -120,26 +120,30 @@ evbuffer_add_printf(struct evbuffer *buf, char *fmt, ...) { int res = -1; char *msg; -#ifdef WIN32 +#ifndef HAVE_VASPRINTF static char buffer[4096]; #endif va_list ap; va_start(ap, fmt); -#ifndef WIN32 +#ifdef HAVE_VASPRINTF if (vasprintf(&msg, fmt, ap) == -1) goto end; #else +# ifdef WIN32 _vsnprintf(buffer, sizeof(buffer) - 1, fmt, ap); buffer[sizeof(buffer)-1] = '\0'; +# else /* ! WIN32 */ + vsnprintf(buffer, sizeof(buffer), fmt, ap); +# endif msg = buffer; #endif res = strlen(msg); if (evbuffer_add(buf, msg, res) == -1) res = -1; -#ifndef WIN32 +#ifdef HAVE_VASPRINTF free(msg); end: