va_list ap;
va_start(ap, format);
- string = alloc_printf(format, ap);
+ string = alloc_vprintf(format, ap);
if (string != NULL)
{
context->output_handler(context, string);
va_list ap;
va_start(ap, format);
- string = alloc_printf(format, ap);
+ string = alloc_vprintf(format, ap);
if (string != NULL)
{
- strcat(string, "\n"); /* alloc_printf guaranteed the buffer to be at least one char longer */
+ strcat(string, "\n"); /* alloc_vprintf guaranteed the buffer to be at least one char longer */
context->output_handler(context, string);
free(string);
}
va_list ap;
va_start(ap, format);
- string = alloc_printf(format, ap);
+ string = alloc_vprintf(format, ap);
if (string != NULL)
{
log_puts(level, file, line, function, string);
va_list ap;
va_start(ap, format);
- string = alloc_printf(format, ap);
+ string = alloc_vprintf(format, ap);
if (string != NULL)
{
- strcat(string, "\n"); /* alloc_printf guaranteed the buffer to be at least one char longer */
+ strcat(string, "\n"); /* alloc_vprintf guaranteed the buffer to be at least one char longer */
log_puts(level, file, line, function, string);
free(string);
}
}
/* return allocated string w/printf() result */
-char *alloc_printf(const char *fmt, va_list ap)
+char *alloc_vprintf(const char *fmt, va_list ap)
{
/* no buffer at the beginning, force realloc to do the job */
char *string = NULL;
int ret;
ret = vsnprintf(string, size, fmt, ap_copy);
-
- va_end(ap_copy);
-
/* NB! The result of the vsnprintf() might be an *EMPTY* string! */
if ((ret >= 0) && ((ret + 1) < size))
break;
/* the returned buffer is by principle guaranteed to be at least one character longer */
return string;
}
+
+char *alloc_printf(const char *format, ...)
+{
+ char *string;
+ va_list ap;
+ va_start(ap, format);
+ string = alloc_vprintf(format, ap);
+ va_end(ap);
+ return string;
+}
extern int log_add_callback(log_callback_fn fn, void *priv);
extern int log_remove_callback(log_callback_fn fn, void *priv);
-char *alloc_printf(const char *fmt, va_list ap);
+char *alloc_vprintf(const char *fmt, va_list ap);
+char *alloc_printf(const char *fmt, ...);
extern int debug_level;