2024-12-05 09:54:33 +00:00
|
|
|
/* crypto_config.h modifier that forces calloc(0) to return NULL.
|
2019-09-17 17:04:38 +00:00
|
|
|
* Used for testing.
|
|
|
|
*/
|
|
|
|
/*
|
2020-08-07 11:07:28 +00: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 17:04:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2021-09-30 07:19:34 +00:00
|
|
|
|
|
|
|
#ifndef MBEDTLS_PLATFORM_STD_CALLOC
|
2023-01-11 13:50:10 +00:00
|
|
|
static inline void *custom_calloc(size_t nmemb, size_t size)
|
2019-09-17 17:04:38 +00:00
|
|
|
{
|
2023-01-11 13:50:10 +00:00
|
|
|
if (nmemb == 0 || size == 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return calloc(nmemb, size);
|
2019-09-17 17:04:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define MBEDTLS_PLATFORM_MEMORY
|
|
|
|
#define MBEDTLS_PLATFORM_STD_CALLOC custom_calloc
|
2021-09-30 07:19:34 +00:00
|
|
|
#endif
|