# HG changeset patch # User Matti Hamalainen # Date 1258492150 -7200 # Node ID ed4067c10a8a124ea719d08588f0adfc9e255104 # Parent 0313fabd8049369ca62f8f77719f5af9b95eff52 Remove useless buffer usage from error reporting function. diff -r 0313fabd8049 -r ed4067c10a8a nnchat.c --- a/nnchat.c Tue Nov 17 23:08:15 2009 +0200 +++ b/nnchat.c Tue Nov 17 23:09:10 2009 +0200 @@ -282,10 +282,9 @@ } -void printMsg(char *fmt, ...) +void printMsgV(const char *fmt, va_list ap) { char tmpStr[128] = "", buf[8192]; - va_list ap; time_t timeStamp; struct tm *tmpTime;; @@ -294,9 +293,7 @@ strftime(tmpStr, sizeof(tmpStr), "½17½[½11½%H:%M:%S½17½]½0½ ", tmpTime); } - va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); if (optLogFile) { printFile(optLogFile, tmpStr); @@ -311,18 +308,27 @@ } } +void printMsg(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + printMsgV(fmt, ap); + va_end(ap); +} + void errorMsg(char *fmt, ...) { - char buf[8192]; - va_list ap; + va_list ap1, ap2; - va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); + va_start(ap1, fmt); + va_copy(ap2, ap1); + printMsgV(fmt, ap1); + va_end(ap1); - printMsg(buf); - THERR(buf); + THERR_V(fmt, ap2); + va_end(ap2); } @@ -645,7 +651,6 @@ } THMSG(2, "True hostname: %s\n", tmpHost->h_name); - #if 1 /* To emulate the official client, we first make a request for * policy file, even though we don't use it for anything... @@ -724,7 +729,7 @@ printEditBuf("", editBuf); updateStatus(insertMode); } - + /* Enter mainloop */ prevTime = time(NULL); FD_ZERO(&sockfds);