未验证 提交 165d6247 编写于 作者: S Sanket Wadekar 提交者: GitHub

log_printf: Restructured log_printf for wrapping (#7567)

上级 3af0b44f
......@@ -496,21 +496,18 @@ int uartGetDebug()
return s_uart_debug_nr;
}
int log_printf(const char *format, ...)
int log_printfv(const char *format, va_list arg)
{
static char loc_buf[64];
char * temp = loc_buf;
int len;
va_list arg;
va_list copy;
va_start(arg, format);
va_copy(copy, arg);
len = vsnprintf(NULL, 0, format, copy);
va_end(copy);
if(len >= sizeof(loc_buf)){
temp = (char*)malloc(len+1);
if(temp == NULL) {
va_end(arg);
return 0;
}
}
......@@ -528,13 +525,22 @@ int log_printf(const char *format, ...)
xSemaphoreGive(_uart_bus_array[s_uart_debug_nr].lock);
}
#endif
va_end(arg);
if(len >= sizeof(loc_buf)){
free(temp);
}
return len;
}
int log_printf(const char *format, ...)
{
int len;
va_list arg;
va_start(arg, format);
len = log_printfv(format, arg);
va_end(arg);
return len;
}
static void log_print_buf_line(const uint8_t *b, size_t len, size_t total_len){
for(size_t i = 0; i<len; i++){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册