Only do dynamic alloc when necessary

This commit is contained in:
Manuel Pégourié-Gonnard 2015-06-29 19:52:44 +02:00
parent 925a72628b
commit 56e245d959

View file

@ -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,