1 /* void * calloc( size_t, size_t )
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
12 void * calloc( size_t nmemb, size_t size )
14 /* assign memory for nmemb elements of given size */
15 void * rc = malloc( nmemb * size );
18 /* zero-initialize the memory */
19 memset( rc, 0, nmemb * size );
28 #include "_PDCLIB_test.h"
33 TESTCASE( ( s = calloc( 3, 2 ) ) != NULL );
34 TESTCASE( s[0] == '\0' );
35 TESTCASE( s[5] == '\0' );
37 TESTCASE( ( s = calloc( 6, 1 ) ) != NULL );
38 TESTCASE( s[0] == '\0' );
39 TESTCASE( s[5] == '\0' );
41 TESTCASE( ( s = calloc( 1, 6 ) ) != NULL );
42 TESTCASE( s[0] == '\0' );
43 TESTCASE( s[5] == '\0' );