| www.delorie.com/gnu/docs/glibc/libc_29.html | search |
![]() Buy the book! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The function calloc allocates memory and clears it to zero. It
is declared in `stdlib.h'.
calloc returns.
You could define calloc as follows:
void *
calloc (size_t count, size_t eltsize)
{
size_t size = count * eltsize;
void *value = malloc (size);
if (value != 0)
memset (value, 0, size);
return value;
}
|
But in general, it is not guaranteed that calloc calls
malloc internally. Therefore, if an application provides its own
malloc/realloc/free outside the C library, it
should always define calloc, too.
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |