calloc.c 192 字节
Newer Older
R
Rich Felker 已提交
1 2 3
#include <stdlib.h>
#include <errno.h>

4 5
void *__malloc0(size_t);

R
Rich Felker 已提交
6 7 8 9 10 11
void *calloc(size_t m, size_t n)
{
	if (n && m > (size_t)-1/n) {
		errno = ENOMEM;
		return 0;
	}
12
	return __malloc0(n * m);
R
Rich Felker 已提交
13
}