Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <fcntl.h>
#include <inttypes.h>
#include <stdatomic.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -199,8 +200,15 @@ void *replacement_realloc(void *ptr, size_t size) {
}

void *replacement_calloc(size_t count, size_t size) {
void *ptr = replacement_malloc(count * size);
memset(ptr, 0, count * size);
if (size != 0 && count > SIZE_MAX / size) {
return NULL;
}

size_t total_size = count * size;
void *ptr = replacement_malloc(total_size);
if (ptr) {
memset(ptr, 0, total_size);
}
return ptr;
}

Expand Down