From b2a18a2a982d292ded81d5f24deeb9724af4c557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 27 May 2015 16:29:56 +0200 Subject: [PATCH] Remove references to malloc in strings/names --- library/ssl_cli.c | 4 ++-- library/ssl_tls.c | 14 +++++++------- programs/test/benchmark.c | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 25a5d0035..ec2b346ef 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -1154,7 +1154,7 @@ static int ssl_parse_hello_verify_request( mbedtls_ssl_context *ssl ) ssl->handshake->verify_cookie = mbedtls_calloc( 1, cookie_len ); if( ssl->handshake->verify_cookie == NULL ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "malloc failed (%d bytes)", cookie_len ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc failed (%d bytes)", cookie_len ) ); return( MBEDTLS_ERR_SSL_MALLOC_FAILED ); } @@ -2913,7 +2913,7 @@ static int ssl_parse_new_session_ticket( mbedtls_ssl_context *ssl ) if( ( ticket = mbedtls_calloc( 1, ticket_len ) ) == NULL ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "ticket malloc failed" ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "ticket alloc failed" ) ); return( MBEDTLS_ERR_SSL_MALLOC_FAILED ); } diff --git a/library/ssl_tls.c b/library/ssl_tls.c index e35382955..fa4d39e50 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -932,7 +932,7 @@ int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl ) ssl->compress_buf = mbedtls_calloc( 1, MBEDTLS_SSL_BUFFER_LEN ); if( ssl->compress_buf == NULL ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "malloc(%d bytes) failed", + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed", MBEDTLS_SSL_BUFFER_LEN ) ); return( MBEDTLS_ERR_SSL_MALLOC_FAILED ); } @@ -2456,14 +2456,14 @@ static int ssl_flight_append( mbedtls_ssl_context *ssl ) /* Allocate space for current message */ if( ( msg = mbedtls_calloc( 1, sizeof( mbedtls_ssl_flight_item ) ) ) == NULL ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "malloc %d bytes failed", + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc %d bytes failed", sizeof( mbedtls_ssl_flight_item ) ) ); return( MBEDTLS_ERR_SSL_MALLOC_FAILED ); } if( ( msg->p = mbedtls_calloc( 1, ssl->out_msglen ) ) == NULL ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "malloc %d bytes failed", ssl->out_msglen ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc %d bytes failed", ssl->out_msglen ) ); mbedtls_free( msg ); return( MBEDTLS_ERR_SSL_MALLOC_FAILED ); } @@ -2927,7 +2927,7 @@ static int ssl_reassemble_dtls_handshake( mbedtls_ssl_context *ssl ) ssl->handshake->hs_msg = mbedtls_calloc( 1, alloc_len ); if( ssl->handshake->hs_msg == NULL ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "malloc failed (%d bytes)", alloc_len ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc failed (%d bytes)", alloc_len ) ); return( MBEDTLS_ERR_SSL_MALLOC_FAILED ); } @@ -3978,7 +3978,7 @@ int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ) if( ( ssl->session_negotiate->peer_cert = mbedtls_calloc( 1, sizeof( mbedtls_x509_crt ) ) ) == NULL ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "malloc(%d bytes) failed", + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed", sizeof( mbedtls_x509_crt ) ) ); return( MBEDTLS_ERR_SSL_MALLOC_FAILED ); } @@ -4916,7 +4916,7 @@ static int ssl_handshake_init( mbedtls_ssl_context *ssl ) ssl->transform_negotiate == NULL || ssl->session_negotiate == NULL ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "malloc() of ssl sub-contexts failed" ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc() of ssl sub-contexts failed" ) ); mbedtls_free( ssl->handshake ); mbedtls_free( ssl->transform_negotiate ); @@ -5005,7 +5005,7 @@ int mbedtls_ssl_setup( mbedtls_ssl_context *ssl, if( ( ssl-> in_buf = mbedtls_calloc( 1, len ) ) == NULL || ( ssl->out_buf = mbedtls_calloc( 1, len ) ) == NULL ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "malloc(%d bytes) failed", len ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed", len ) ); mbedtls_free( ssl->in_buf ); ssl->in_buf = NULL; return( MBEDTLS_ERR_SSL_MALLOC_FAILED ); diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c index ca08f5425..6262d339b 100644 --- a/programs/test/benchmark.c +++ b/programs/test/benchmark.c @@ -87,7 +87,7 @@ int main( void ) #define MEM_BLOCK_OVERHEAD ( 2 * sizeof( size_t ) ) /* - * Size to use for the malloc buffer if MEMORY_BUFFER_ALLOC_C is defined. + * Size to use for the alloc buffer if MEMORY_BUFFER_ALLOC_C is defined. */ #define HEAP_SIZE (1u << 16) // 64k @@ -253,7 +253,7 @@ int main( int argc, char *argv[] ) char title[TITLE_LEN]; todo_list todo; #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) - unsigned char malloc_buf[HEAP_SIZE] = { 0 }; + unsigned char alloc_buf[HEAP_SIZE] = { 0 }; #endif if( argc <= 1 ) @@ -319,7 +319,7 @@ int main( int argc, char *argv[] ) mbedtls_printf( "\n" ); #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) - mbedtls_memory_buffer_alloc_init( malloc_buf, sizeof( malloc_buf ) ); + mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof( alloc_buf ) ); #endif memset( buf, 0xAA, sizeof( buf ) ); memset( tmp, 0xBB, sizeof( tmp ) );