2024-12-05 10:54:33 +01:00
|
|
|
/* crypto_config.h modifier that forces calloc(0) to return NULL.
|
2019-09-17 19:04:38 +02:00
|
|
|
* Used for testing.
|
|
|
|
*/
|
|
|
|
/*
|
2020-08-07 13:07:28 +02:00
|
|
|
* Copyright The Mbed TLS Contributors
|
2023-11-02 19:47:20 +00:00
|
|
|
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
2019-09-17 19:04:38 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2021-09-30 17:19:34 +10:00
|
|
|
|
|
|
|
#ifndef MBEDTLS_PLATFORM_STD_CALLOC
|
2023-01-11 14:50:10 +01:00
|
|
|
static inline void *custom_calloc(size_t nmemb, size_t size)
|
2019-09-17 19:04:38 +02:00
|
|
|
{
|
2023-01-11 14:50:10 +01:00
|
|
|
if (nmemb == 0 || size == 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return calloc(nmemb, size);
|
2019-09-17 19:04:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define MBEDTLS_PLATFORM_MEMORY
|
|
|
|
#define MBEDTLS_PLATFORM_STD_CALLOC custom_calloc
|
2021-09-30 17:19:34 +10:00
|
|
|
#endif
|