source: trunk/libs/newlib/src/newlib/libc/stdlib/calloc.c @ 577

Last change on this file since 577 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

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