2021-05-09 17:34:00 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2020-09-17 19:27:01 +02:00
|
|
|
|
|
|
|
void *calloc(size_t nmemb, size_t size)
|
|
|
|
{
|
2021-06-07 21:54:55 +02:00
|
|
|
unsigned int total_size;
|
2020-09-17 19:27:01 +02:00
|
|
|
|
2021-06-07 21:54:55 +02:00
|
|
|
if(__builtin_umul_overflow(nmemb, size, &total_size))
|
|
|
|
return NULL;
|
2020-09-17 19:27:01 +02:00
|
|
|
|
2021-06-07 21:54:55 +02:00
|
|
|
void *mem = malloc(total_size);
|
2021-09-25 15:16:24 +02:00
|
|
|
if(mem) memset(mem, 0, total_size);
|
2021-06-07 21:54:55 +02:00
|
|
|
return mem;
|
2020-09-17 19:27:01 +02:00
|
|
|
}
|