5 /* void * calloc( size_t, size_t )
7 This file is part of the Public Domain C Library (PDCLib).
8 Permission is granted to use, modify, and / or redistribute at will.
16 void * calloc( size_t nmemb, size_t size )
18 /* assign memory for nmemb elements of given size */
19 void * rc = malloc( nmemb * size );
22 /* zero-initialize the memory */
23 memset( rc, 0, nmemb * size );
31 #include <_PDCLIB_test.h>
37 TESTCASE( ( s = calloc( 3, 2 ) ) != NULL );
38 TESTCASE( s[0] == '\0' );
39 TESTCASE( s[5] == '\0' );
41 TESTCASE( ( s = calloc( 6, 1 ) ) != NULL );
42 TESTCASE( s[0] == '\0' );
43 TESTCASE( s[5] == '\0' );
45 TESTCASE( ( s = calloc( 1, 6 ) ) != NULL );
46 TESTCASE( s[0] == '\0' );
47 TESTCASE( s[5] == '\0' );