From 56e245d9598a3a1abe9d2d3746f645fa71c2563b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 29 Jun 2015 19:52:44 +0200 Subject: [PATCH] Only do dynamic alloc when necessary --- library/debug.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/debug.c b/library/debug.c index d23e87b91..0aa90e1b2 100644 --- a/library/debug.c +++ b/library/debug.c @@ -70,10 +70,14 @@ void debug_set_threshold( int threshold ) char *debug_fmt( const char *format, ... ) { va_list argp; +#if defined(POLARSSL_THREADING_C) char *str = polarssl_malloc( DEBUG_BUF_SIZE ); if( str == NULL ) return( NULL ); +#else + static char str[DEBUG_BUF_SIZE]; +#endif va_start( argp, format ); vsnprintf( str, DEBUG_BUF_SIZE - 1, format, argp ); @@ -89,7 +93,9 @@ void debug_print_msg_free( const ssl_context *ssl, int level, if( text != NULL ) debug_print_msg( ssl, level, file, line, text ); +#if defined(POLARSSL_THREADING_C) polarssl_free( text ); +#endif } void debug_print_msg( const ssl_context *ssl, int level,