1) Why code under /* test1 */ chunk do not print out anything, but code under /* test2 */ print correctly?
2) How to use va_arg(va, char*) in /* test 1 */ code chunk.
void rdfDBG(int dbglevel, const char *fmt, ...) {
va_list va;
#if 1 /* test 1 */
char* logbuf;
if ((logbuf = calloc(0x0, LOGBUFFERSIZE))== NULL)
fprintf(stderr, "out of memory\n"); /* 1. Is there a better way instead of using fprintf? */
va_start(va, fmt);
(void) vsnprintf(logbuf, strlen(logbuf), fmt, va); /* 2. print nothing */
va_end(va);
free(logbuf);
#endif
#if 0 /* test 2 */
va_start(va, fmt);
vprintf(fmt, va); /* 2. print "pinfile pings6.txt" */
va_end(va);
#endif
}
int ptInitialize(){
char* pinfile;
pinfile = "pings6.txt";
rdfDBG(kINFO, "pinfile %s\n", pinfile);
return 0;
}