summaryrefslogtreecommitdiff
path: root/klibc/klibc/calloc.c
blob: 228a1b70e4afbf56f240f0e0555a66523fa0c669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * calloc.c
 */

#include <stdlib.h>
#include <string.h>

/* FIXME: This should look for multiplication overflow */

void *calloc(size_t nmemb, size_t size)
{
  void *ptr;

  size *= nmemb;
  ptr = malloc(size);
  if ( ptr )
    memset(ptr, 0, size);

  return ptr;
}