1 /* mbedtls_config.h modifier that forces calloc(0) to return NULL.
2  * Used for testing.
3  */
4 /*
5  *  Copyright The Mbed TLS Contributors
6  *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7  */
8 
9 #include <stdlib.h>
10 
11 #ifndef MBEDTLS_PLATFORM_STD_CALLOC
custom_calloc(size_t nmemb,size_t size)12 static inline void *custom_calloc(size_t nmemb, size_t size)
13 {
14     if (nmemb == 0 || size == 0) {
15         return NULL;
16     }
17     return calloc(nmemb, size);
18 }
19 
20 #define MBEDTLS_PLATFORM_MEMORY
21 #define MBEDTLS_PLATFORM_STD_CALLOC custom_calloc
22 #endif
23