summaryrefslogtreecommitdiff
path: root/library/platform.c
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2015-05-26 16:15:20 +0200
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2015-05-27 16:58:55 +0200
commitb9ef1182f379ca1835e1082d282490ec49cf128e (patch)
tree2cdf894cef5bd18cbce8a95ecbeeb75d619d2ac1 /library/platform.c
parent7551cb9ee9b13da9c03b56b643f813303c8056c8 (diff)
Adapt the platform layer from malloc to calloc
Diffstat (limited to 'library/platform.c')
-rw-r--r--library/platform.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/library/platform.c b/library/platform.c
index 788cd1f7..e9ab3024 100644
--- a/library/platform.c
+++ b/library/platform.c
@@ -31,15 +31,16 @@
#include "mbedtls/platform.h"
#if defined(MBEDTLS_PLATFORM_MEMORY)
-#if !defined(MBEDTLS_PLATFORM_STD_MALLOC)
-static void *platform_malloc_uninit( size_t len )
+#if !defined(MBEDTLS_PLATFORM_STD_CALLOC)
+static void *platform_calloc_uninit( size_t n, size_t size )
{
- ((void) len);
+ ((void) n);
+ ((void) size);
return( NULL );
}
-#define MBEDTLS_PLATFORM_STD_MALLOC platform_malloc_uninit
-#endif /* !MBEDTLS_PLATFORM_STD_MALLOC */
+#define MBEDTLS_PLATFORM_STD_CALLOC platform_calloc_uninit
+#endif /* !MBEDTLS_PLATFORM_STD_CALLOC */
#if !defined(MBEDTLS_PLATFORM_STD_FREE)
static void platform_free_uninit( void *ptr )
@@ -50,13 +51,13 @@ static void platform_free_uninit( void *ptr )
#define MBEDTLS_PLATFORM_STD_FREE platform_free_uninit
#endif /* !MBEDTLS_PLATFORM_STD_FREE */
-void * (*mbedtls_malloc)( size_t ) = MBEDTLS_PLATFORM_STD_MALLOC;
+void * (*mbedtls_calloc)( size_t, size_t ) = MBEDTLS_PLATFORM_STD_CALLOC;
void (*mbedtls_free)( void * ) = MBEDTLS_PLATFORM_STD_FREE;
-int mbedtls_platform_set_malloc_free( void * (*malloc_func)( size_t ),
+int mbedtls_platform_set_calloc_free( void * (*calloc_func)( size_t, size_t ),
void (*free_func)( void * ) )
{
- mbedtls_malloc = malloc_func;
+ mbedtls_calloc = calloc_func;
mbedtls_free = free_func;
return( 0 );
}