Skip to content

Commit

Permalink
allocator: add support for calloc
Browse files Browse the repository at this point in the history
Signed-off-by: Mahavir Jain <[email protected]>
  • Loading branch information
mahavirj authored and Mahavir Jain committed Apr 1, 2017
1 parent 2ed2107 commit ab60e01
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions stdlib/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,11 @@ void *malloc(size_t size)
dbg("Rquired size unable to allocate %d\n", size - sizeof(node_t));
return NULL;
}

void *calloc(size_t nmemb, size_t size)
{
void *p = malloc(nmemb * size);
if (p)
memset(p, 0, nmemb * size);
return p;
}

0 comments on commit ab60e01

Please sign in to comment.