1 /*
2 Copyright (c) 1990 Regents of the University of California.
3 All rights reserved.
4  */
5 #ifdef MALLOC_PROVIDED
6 int _dummy_calloc = 1;
7 #else
8 /*
9 FUNCTION
10 <<calloc>>---allocate space for arrays
11 
12 INDEX
13 	calloc
14 
15 INDEX
16 	_calloc_r
17 
18 SYNOPSIS
19 	#include <stdlib.h>
20 	void *calloc(size_t <[n]>, size_t <[s]>);
21 	void *_calloc_r(void *<[reent]>, size_t <[n]>, size_t <[s]>);
22 
23 DESCRIPTION
24 Use <<calloc>> to request a block of memory sufficient to hold an
25 array of <[n]> elements, each of which has size <[s]>.
26 
27 The memory allocated by <<calloc>> comes out of the same memory pool
28 used by <<malloc>>, but the memory block is initialized to all zero
29 bytes.  (To avoid the overhead of initializing the space, use
30 <<malloc>> instead.)
31 
32 The alternate function <<_calloc_r>> is reentrant.
33 The extra argument <[reent]> is a pointer to a reentrancy structure.
34 
35 RETURNS
36 If successful, a pointer to the newly allocated space.
37 
38 If unsuccessful, <<NULL>>.
39 
40 PORTABILITY
41 <<calloc>> is ANSI.
42 
43 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
44 <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
45 */
46 
47 #include <string.h>
48 #include <stdlib.h>
49 
50 #ifndef _REENT_ONLY
51 
52 void *
calloc(size_t n,size_t size)53 calloc (size_t n,
54 	size_t size)
55 {
56   return _calloc_r (_REENT, n, size);
57 }
58 
59 #endif
60 #endif /* MALLOC_PROVIDED */
61