Rename mbedtls_net_close() to mbedtls_net_free()

close() may be more meaningful, but free() is symmetric with _init(), and more
consistent with all other modules
This commit is contained in:
Manuel Pégourié-Gonnard 2015-06-30 15:55:03 +02:00
parent 5db64328ab
commit 3d7d00ad23
18 changed files with 36 additions and 36 deletions

View File

@ -2157,7 +2157,7 @@
#define mpi_write_string mbedtls_mpi_write_string #define mpi_write_string mbedtls_mpi_write_string
#define net_accept mbedtls_net_accept #define net_accept mbedtls_net_accept
#define net_bind mbedtls_net_bind #define net_bind mbedtls_net_bind
#define net_close mbedtls_net_close #define net_close mbedtls_net_free
#define net_connect mbedtls_net_connect #define net_connect mbedtls_net_connect
#define net_recv mbedtls_net_recv #define net_recv mbedtls_net_recv
#define net_recv_timeout mbedtls_net_recv_timeout #define net_recv_timeout mbedtls_net_recv_timeout

View File

@ -216,11 +216,11 @@ int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
uint32_t timeout ); uint32_t timeout );
/** /**
* \brief Gracefully shutdown the connection * \brief Gracefully shutdown the connection and free associated data
* *
* \param ctx The socket to close * \param ctx The context to free
*/ */
void mbedtls_net_close( mbedtls_net_context *ctx ); void mbedtls_net_free( mbedtls_net_context *ctx );
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -521,7 +521,7 @@ int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len )
/* /*
* Gracefully close the connection * Gracefully close the connection
*/ */
void mbedtls_net_close( mbedtls_net_context *ctx ) void mbedtls_net_free( mbedtls_net_context *ctx )
{ {
if( ctx->fd == -1 ) if( ctx->fd == -1 )
return; return;

View File

@ -281,7 +281,7 @@ int main( void )
exit: exit:
mbedtls_net_close( &server_fd ); mbedtls_net_free( &server_fd );
mbedtls_aes_free( &aes ); mbedtls_aes_free( &aes );
mbedtls_rsa_free( &rsa ); mbedtls_rsa_free( &rsa );

View File

@ -283,8 +283,8 @@ int main( void )
exit: exit:
mbedtls_net_close( &client_fd ); mbedtls_net_free( &client_fd );
mbedtls_net_close( &listen_fd ); mbedtls_net_free( &listen_fd );
mbedtls_aes_free( &aes ); mbedtls_aes_free( &aes );
mbedtls_rsa_free( &rsa ); mbedtls_rsa_free( &rsa );

View File

@ -326,7 +326,7 @@ exit:
} }
#endif #endif
mbedtls_net_close( &server_fd ); mbedtls_net_free( &server_fd );
mbedtls_x509_crt_free( &cacert ); mbedtls_x509_crt_free( &cacert );
mbedtls_ssl_free( &ssl ); mbedtls_ssl_free( &ssl );

View File

@ -256,7 +256,7 @@ reset:
} }
#endif #endif
mbedtls_net_close( &client_fd ); mbedtls_net_free( &client_fd );
mbedtls_ssl_session_reset( &ssl ); mbedtls_ssl_session_reset( &ssl );
@ -401,8 +401,8 @@ exit:
} }
#endif #endif
mbedtls_net_close( &client_fd ); mbedtls_net_free( &client_fd );
mbedtls_net_close( &listen_fd ); mbedtls_net_free( &listen_fd );
mbedtls_x509_crt_free( &srvcert ); mbedtls_x509_crt_free( &srvcert );
mbedtls_pk_free( &pkey ); mbedtls_pk_free( &pkey );

View File

@ -280,7 +280,7 @@ int main( void )
mbedtls_ssl_close_notify( &ssl ); mbedtls_ssl_close_notify( &ssl );
exit: exit:
mbedtls_net_close( &server_fd ); mbedtls_net_free( &server_fd );
mbedtls_ssl_free( &ssl ); mbedtls_ssl_free( &ssl );
mbedtls_ssl_config_free( &conf ); mbedtls_ssl_config_free( &conf );

View File

@ -290,7 +290,7 @@ exit:
} }
#endif #endif
mbedtls_net_close( &server_fd ); mbedtls_net_free( &server_fd );
mbedtls_x509_crt_free( &cacert ); mbedtls_x509_crt_free( &cacert );
mbedtls_ssl_free( &ssl ); mbedtls_ssl_free( &ssl );

View File

@ -1503,7 +1503,7 @@ reconnect:
{ {
--opt.reconnect; --opt.reconnect;
mbedtls_net_close( &server_fd ); mbedtls_net_free( &server_fd );
#if defined(MBEDTLS_TIMING_C) #if defined(MBEDTLS_TIMING_C)
if( opt.reco_delay > 0 ) if( opt.reco_delay > 0 )
@ -1572,7 +1572,7 @@ exit:
} }
#endif #endif
mbedtls_net_close( &server_fd ); mbedtls_net_free( &server_fd );
#if defined(MBEDTLS_X509_CRT_PARSE_C) #if defined(MBEDTLS_X509_CRT_PARSE_C)
mbedtls_x509_crt_free( &clicert ); mbedtls_x509_crt_free( &clicert );

View File

@ -259,11 +259,11 @@ int main( void )
goto exit; goto exit;
} }
mbedtls_net_close( &client_fd ); mbedtls_net_free( &client_fd );
continue; continue;
} }
mbedtls_net_close( &listen_fd ); mbedtls_net_free( &listen_fd );
/* /*
* 4. Setup stuff * 4. Setup stuff
@ -385,8 +385,8 @@ int main( void )
} }
exit: exit:
mbedtls_net_close( &client_fd ); mbedtls_net_free( &client_fd );
mbedtls_net_close( &listen_fd ); mbedtls_net_free( &listen_fd );
mbedtls_x509_crt_free( &srvcert ); mbedtls_x509_crt_free( &srvcert );
mbedtls_pk_free( &pkey ); mbedtls_pk_free( &pkey );

View File

@ -819,7 +819,7 @@ int main( int argc, char *argv[] )
exit: exit:
mbedtls_net_close( &server_fd ); mbedtls_net_free( &server_fd );
mbedtls_x509_crt_free( &clicert ); mbedtls_x509_crt_free( &clicert );
mbedtls_x509_crt_free( &cacert ); mbedtls_x509_crt_free( &cacert );
mbedtls_pk_free( &pkey ); mbedtls_pk_free( &pkey );

View File

@ -265,7 +265,7 @@ thread_exit:
} }
#endif #endif
mbedtls_net_close( client_fd ); mbedtls_net_free( client_fd );
mbedtls_ssl_free( &ssl ); mbedtls_ssl_free( &ssl );
thread_info->thread_complete = 1; thread_info->thread_complete = 1;
@ -491,7 +491,7 @@ reset:
if( ( ret = thread_create( &client_fd ) ) != 0 ) if( ( ret = thread_create( &client_fd ) ) != 0 )
{ {
mbedtls_printf( " [ main ] failed: thread_create returned %d\n", ret ); mbedtls_printf( " [ main ] failed: thread_create returned %d\n", ret );
mbedtls_net_close( &client_fd ); mbedtls_net_free( &client_fd );
goto reset; goto reset;
} }

View File

@ -237,7 +237,7 @@ reset:
} }
#endif #endif
mbedtls_net_close( &client_fd ); mbedtls_net_free( &client_fd );
mbedtls_ssl_session_reset( &ssl ); mbedtls_ssl_session_reset( &ssl );
@ -373,8 +373,8 @@ exit:
} }
#endif #endif
mbedtls_net_close( &client_fd ); mbedtls_net_free( &client_fd );
mbedtls_net_close( &listen_fd ); mbedtls_net_free( &listen_fd );
mbedtls_x509_crt_free( &srvcert ); mbedtls_x509_crt_free( &srvcert );
mbedtls_pk_free( &pkey ); mbedtls_pk_free( &pkey );

View File

@ -755,8 +755,8 @@ void term_handler( int sig )
{ {
((void) sig); ((void) sig);
received_sigterm = 1; received_sigterm = 1;
mbedtls_net_close( &listen_fd ); /* causes mbedtls_net_accept() to abort */ mbedtls_net_free( &listen_fd ); /* causes mbedtls_net_accept() to abort */
mbedtls_net_close( &client_fd ); /* causes net_read() to abort */ mbedtls_net_free( &client_fd ); /* causes net_read() to abort */
} }
#endif #endif
@ -1843,7 +1843,7 @@ reset:
} }
#endif #endif
mbedtls_net_close( &client_fd ); mbedtls_net_free( &client_fd );
mbedtls_ssl_session_reset( &ssl ); mbedtls_ssl_session_reset( &ssl );
@ -2252,8 +2252,8 @@ exit:
mbedtls_printf( " . Cleaning up..." ); mbedtls_printf( " . Cleaning up..." );
fflush( stdout ); fflush( stdout );
mbedtls_net_close( &client_fd ); mbedtls_net_free( &client_fd );
mbedtls_net_close( &listen_fd ); mbedtls_net_free( &listen_fd );
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO)
mbedtls_dhm_free( &dhm ); mbedtls_dhm_free( &dhm );

View File

@ -615,9 +615,9 @@ exit:
} }
#endif #endif
mbedtls_net_close( &client_fd ); mbedtls_net_free( &client_fd );
mbedtls_net_close( &server_fd ); mbedtls_net_free( &server_fd );
mbedtls_net_close( &listen_fd ); mbedtls_net_free( &listen_fd );
#if defined(_WIN32) #if defined(_WIN32)
mbedtls_printf( " Press Enter to exit this program.\n" ); mbedtls_printf( " Press Enter to exit this program.\n" );

View File

@ -475,7 +475,7 @@ ssl_exit:
exit: exit:
mbedtls_net_close( &server_fd ); mbedtls_net_free( &server_fd );
mbedtls_x509_crt_free( &cacert ); mbedtls_x509_crt_free( &cacert );
mbedtls_x509_crt_free( &clicert ); mbedtls_x509_crt_free( &clicert );
#if defined(MBEDTLS_X509_CRL_PARSE_C) #if defined(MBEDTLS_X509_CRL_PARSE_C)

View File

@ -1701,7 +1701,7 @@ mpi_write_file mbedtls_mpi_write_file
mpi_write_string mbedtls_mpi_write_string mpi_write_string mbedtls_mpi_write_string
net_accept mbedtls_net_accept net_accept mbedtls_net_accept
net_bind mbedtls_net_bind net_bind mbedtls_net_bind
net_close mbedtls_net_close net_close mbedtls_net_free
net_connect mbedtls_net_connect net_connect mbedtls_net_connect
net_recv mbedtls_net_recv net_recv mbedtls_net_recv
net_recv_timeout mbedtls_net_recv_timeout net_recv_timeout mbedtls_net_recv_timeout