From d7a17ac941dae613ca2c32bfd17cef905ea23e67 Mon Sep 17 00:00:00 2001 From: Jason von Nieda Date: Fri, 27 Jul 2018 12:03:01 -0500 Subject: [PATCH] Adds a Kconfig option for mbedtls' MBEDTLS_PLATFORM_MEMORY define. This makes it possible to override the mbedtls allocator with your own. Merges https://github.com/espressif/esp-idf/pull/2237 --- components/mbedtls/Kconfig | 16 ++++++++++++++++ .../mbedtls/port/include/mbedtls/esp_config.h | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/components/mbedtls/Kconfig b/components/mbedtls/Kconfig index f1016f5c2..89e08beb6 100644 --- a/components/mbedtls/Kconfig +++ b/components/mbedtls/Kconfig @@ -1,5 +1,21 @@ menu "mbedTLS" +config MBEDTLS_PLATFORM_MEMORY + bool "Enable custom mbedTLS memory allocation layer." + default n + help + If this option is disabled, mbed TLS uses the default system + calloc() and free() functions. + + If this option is enabled, the mbed TLS config macro + MBEDTLS_PLATFORM_MEMORY will be defined. The function + mbedtls_platform_set_calloc_free() must be called at + runtime to provide custom calloc() and free() function + pointers for use by mbedTLS. + + This option allows fine-grained control over how mbedTLS + allocates heap memory. + config MBEDTLS_SSL_MAX_CONTENT_LEN int "TLS maximum message content length" default 16384 diff --git a/components/mbedtls/port/include/mbedtls/esp_config.h b/components/mbedtls/port/include/mbedtls/esp_config.h index c81bf1a06..561ff723c 100644 --- a/components/mbedtls/port/include/mbedtls/esp_config.h +++ b/components/mbedtls/port/include/mbedtls/esp_config.h @@ -114,7 +114,9 @@ * * Enable this layer to allow use of alternative memory allocators. */ -//#define MBEDTLS_PLATFORM_MEMORY +#ifdef CONFIG_MBEDTLS_PLATFORM_MEMORY +#define MBEDTLS_PLATFORM_MEMORY +#endif /** * \def MBEDTLS_PLATFORM_NO_STD_FUNCTIONS