Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / stdlib / calloc.c
blob208e27eb10100c15987597101bccca741a96ba23
1 #ifdef MALLOC_PROVIDED
2 int _dummy_calloc = 1;
3 #else
4 /*
5 FUNCTION
6 <<calloc>>---allocate space for arrays
8 INDEX
9 calloc
11 INDEX
12 _calloc_r
14 SYNOPSIS
15 #include <stdlib.h>
16 void *calloc(size_t <[n]>, size_t <[s]>);
17 void *_calloc_r(void *<[reent]>, size_t <[n]>, size_t <[s]>);
19 DESCRIPTION
20 Use <<calloc>> to request a block of memory sufficient to hold an
21 array of <[n]> elements, each of which has size <[s]>.
23 The memory allocated by <<calloc>> comes out of the same memory pool
24 used by <<malloc>>, but the memory block is initialized to all zero
25 bytes. (To avoid the overhead of initializing the space, use
26 <<malloc>> instead.)
28 The alternate function <<_calloc_r>> is reentrant.
29 The extra argument <[reent]> is a pointer to a reentrancy structure.
31 RETURNS
32 If successful, a pointer to the newly allocated space.
34 If unsuccessful, <<NULL>>.
36 PORTABILITY
37 <<calloc>> is ANSI.
39 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
40 <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
43 #include <string.h>
44 #include <stdlib.h>
46 #ifndef _REENT_ONLY
48 void *
49 calloc (size_t n,
50 size_t size)
52 return _calloc_r (_REENT, n, size);
55 #endif
56 #endif /* MALLOC_PROVIDED */