Skip to content

Commit

Permalink
Implement calloc
Browse files Browse the repository at this point in the history
  • Loading branch information
pipe01 committed Nov 30, 2024
1 parent 1355737 commit d295791
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/stdlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ void __wrap_free(void* ptr) {
}

void* calloc(size_t num, size_t size) {
(void) num;
(void) size;
// Not supported
return NULL;
void *ptr = malloc(num * size);
if (ptr) {
memset(ptr, 0, num * size);
}
return ptr;
}

void* __wrap_calloc(size_t num, size_t size) {
Expand Down

0 comments on commit d295791

Please sign in to comment.