X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstdlib%2Fcalloc.c;h=a9a485fee3ff64c7e4fa64492843e146c31f7f6b;hp=5470427f4c3306d9caeb31a8744caf746184db0e;hb=1d9d92ba957a0b8307c9a65c35867fde68e6533b;hpb=34893ecc2200dc7017c36a54cb6c5f4c2378b5ec diff --git a/functions/stdlib/calloc.c b/functions/stdlib/calloc.c index 5470427..a9a485f 100644 --- a/functions/stdlib/calloc.c +++ b/functions/stdlib/calloc.c @@ -1,8 +1,34 @@ -// ---------------------------------------------------------------------------- -// $Id$ -// ---------------------------------------------------------------------------- -// Public Domain C Library - http://pdclib.sourceforge.net -// This code is Public Domain. Use, modify, and redistribute at will. -// ---------------------------------------------------------------------------- +/* ---------------------------------------------------------------------------- + * $Id$ + * ---------------------------------------------------------------------------- + * Public Domain C Library - http://pdclib.sourceforge.net + * This code is Public Domain. Use, modify, and redistribute at will. + * --------------------------------------------------------------------------*/ void * calloc( size_t nelem, size_t size ) { /* TODO */ }; + +/* PDPC code - unreviewed +{ + void *ptr; + size_t total; + + if (nmemb == 1) + { + total = size; + } + else if (size == 1) + { + total = nmemb; + } + else + { + total = nmemb * size; + } + ptr = malloc(total); + if (ptr != NULL) + { + memset(ptr, '\0', total); + } + return (ptr); +} +*/