Replace malloc with calloc
- platform layer currently broken (not adapted yet)
- memmory_buffer_alloc too
diff --git a/library/pk_wrap.c b/library/pk_wrap.c
index 7a47511..7012b12 100644
--- a/library/pk_wrap.c
+++ b/library/pk_wrap.c
@@ -46,7 +46,7 @@
#include "mbedtls/platform.h"
#else
#include <stdlib.h>
-#define mbedtls_malloc malloc
+#define mbedtls_calloc calloc
#define mbedtls_free free
#endif
@@ -134,7 +134,7 @@
static void *rsa_alloc_wrap( void )
{
- void *ctx = mbedtls_malloc( sizeof( mbedtls_rsa_context ) );
+ void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_rsa_context ) );
if( ctx != NULL )
mbedtls_rsa_init( (mbedtls_rsa_context *) ctx, 0, 0 );
@@ -250,7 +250,7 @@
static void *eckey_alloc_wrap( void )
{
- void *ctx = mbedtls_malloc( sizeof( mbedtls_ecp_keypair ) );
+ void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecp_keypair ) );
if( ctx != NULL )
mbedtls_ecp_keypair_init( ctx );
@@ -349,7 +349,7 @@
static void *ecdsa_alloc_wrap( void )
{
- void *ctx = mbedtls_malloc( sizeof( mbedtls_ecdsa_context ) );
+ void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecdsa_context ) );
if( ctx != NULL )
mbedtls_ecdsa_init( (mbedtls_ecdsa_context *) ctx );
@@ -458,7 +458,7 @@
static void *rsa_alt_alloc_wrap( void )
{
- void *ctx = mbedtls_malloc( sizeof( mbedtls_rsa_alt_context ) );
+ void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_rsa_alt_context ) );
if( ctx != NULL )
memset( ctx, 0, sizeof( mbedtls_rsa_alt_context ) );