Migrated the Memory layer to the Platform layer

Deprecated POLARSSL_MEMORY_C and placed placeholder for memory.h to make
sure current code will not break on new version.
This commit is contained in:
Paul Bakker 2014-02-04 17:30:24 +01:00
parent b2f66c9158
commit defc0ca337
9 changed files with 199 additions and 183 deletions

View file

@ -38,13 +38,27 @@ extern "C" {
#if !defined(POLARSSL_CONFIG_OPTIONS)
#define POLARSSL_PLATFORM_STD_PRINTF printf /**< Default printf to use */
#define POLARSSL_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use */
#define POLARSSL_PLATFORM_STD_MALLOC malloc /**< Default allocator to use */
#define POLARSSL_PLATFORM_STD_FREE free /**< Default free to use */
#endif /* POLARSSL_CONFIG_OPTIONS */
/*
* The function pointers for malloc and free
*/
#if defined(POLARSSL_MEMORY_C)
#include "memory.h"
extern void * (*polarssl_malloc)( size_t len );
extern void (*polarssl_free)( void *ptr );
/**
* \brief Set your own memory implementation function pointers
*
* \param malloc_func the malloc function implementation
* \param free_func the free function implementation
*
* \return 0 if successful
*/
int platform_set_malloc_free( void * (*malloc_func)( size_t ),
void (*free_func)( void * ) );
#else
#include <stdlib.h>
#define polarssl_malloc malloc