X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Fcalloc.c;h=abb63b08fa3ff02b47b0d744a372be656b6b5164;hb=d6f1494a4f38a212b29a13ee713885058dcf0fe7;hp=1e568b4303551e4467ef721d35820082612d5981;hpb=2af1ca8cfb0375c80c1ca72ded9260280494c8e2;p=pdclib diff --git a/functions/stdlib/calloc.c b/functions/stdlib/calloc.c index 1e568b4..abb63b0 100644 --- a/functions/stdlib/calloc.c +++ b/functions/stdlib/calloc.c @@ -1,7 +1,3 @@ -/* $Id$ */ - -/* Release $Name$ */ - /* void * calloc( size_t, size_t ) This file is part of the Public Domain C Library (PDCLib). @@ -15,9 +11,11 @@ void * calloc( size_t nmemb, size_t size ) { + /* assign memory for nmemb elements of given size */ void * rc = malloc( nmemb * size ); if ( rc != NULL ) { + /* zero-initialize the memory */ memset( rc, 0, nmemb * size ); } return rc; @@ -26,12 +24,11 @@ void * calloc( size_t nmemb, size_t size ) #endif #ifdef TEST -#include <_PDCLIB_test.h> +#include "_PDCLIB_test.h" -int main() +int main( void ) { char * s; - BEGIN_TESTS; TESTCASE( ( s = calloc( 3, 2 ) ) != NULL ); TESTCASE( s[0] == '\0' ); TESTCASE( s[5] == '\0' );