From a80a0442fd397fc6aa4f3b2d8537c0cabb857e4b Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Tue, 6 Sep 2011 17:38:27 +0200 Subject: fix compile errors --- customdhcpcd/src/logwriter.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'customdhcpcd/src/logwriter.c') diff --git a/customdhcpcd/src/logwriter.c b/customdhcpcd/src/logwriter.c index 0a78995..d41bbfb 100644 --- a/customdhcpcd/src/logwriter.c +++ b/customdhcpcd/src/logwriter.c @@ -151,10 +151,23 @@ void logSendToQt(int type) { } } -void logLoggerToQt(int level, const char *fmt, va_list args) { - vsnprintf(mesg, sizeof(mesg), fmt, args); - strcat(mesg, "\n"); - logToQt(level, DHCPCD_LOG, mesg); +void logLoggerToQt(int level, const char *fmt, ...) { + // Format string into buffer + va_list argptr; + va_start (argptr, fmt); + int size = 255 + 2; + char *string = (char *) malloc (size); + int required = vsnprintf (string, size, fmt, argptr); + if (required >= size) + { + size = required + 2; + string = (char *) realloc (string, size); + vsnprintf (string, size, fmt, argptr); + } + va_end (argptr); + + strcat(string, "\n"); + logToQt(level, DHCPCD_LOG, string); } static void print_addresses (FILE *f, const struct address_head *addresses) -- cgit v1.2.3-55-g7522