3 /* void * calloc( size_t, size_t )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
14 void * calloc( size_t nmemb, size_t size )
16 /* assign memory for nmemb elements of given size */
17 void * rc = malloc( nmemb * size );
20 /* zero-initialize the memory */
21 memset( rc, 0, nmemb * size );
29 #include <_PDCLIB_test.h>
34 TESTCASE( ( s = calloc( 3, 2 ) ) != NULL );
35 TESTCASE( s[0] == '\0' );
36 TESTCASE( s[5] == '\0' );
38 TESTCASE( ( s = calloc( 6, 1 ) ) != NULL );
39 TESTCASE( s[0] == '\0' );
40 TESTCASE( s[5] == '\0' );
42 TESTCASE( ( s = calloc( 1, 6 ) ) != NULL );
43 TESTCASE( s[0] == '\0' );
44 TESTCASE( s[5] == '\0' );