aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/tests/ansi/calloc.c
blob: 6cfc87d8859ecd31005e0daeb77afb910989008f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>

int main() {
	errno = 0;
	void *ptr = calloc((SIZE_MAX / 2) + 2, 2);
	assert(!ptr);
	assert(errno);

	errno = 0;
	ptr = calloc(sizeof(size_t), 10);
	assert(ptr);
	for(size_t i = 0; i < 10; i++) {
		size_t *p = ptr;
		assert(!p[i]);
	}
}