OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [stdlib/] [calloc.c] - Blame information for rev 39

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.