4.115
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Allocate Space for Array in Memory |
---|
5 | * @ingroup libcsupport |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2007. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #if defined(RTEMS_NEWLIB) && !defined(HAVE_CALLOC) |
---|
22 | #include "malloc_p.h" |
---|
23 | #include <stdlib.h> |
---|
24 | #include <string.h> |
---|
25 | |
---|
26 | void *calloc( |
---|
27 | size_t nelem, |
---|
28 | size_t elsize |
---|
29 | ) |
---|
30 | { |
---|
31 | register char *cptr; |
---|
32 | size_t length; |
---|
33 | |
---|
34 | MSBUMP(calloc_calls, 1); |
---|
35 | |
---|
36 | length = nelem * elsize; |
---|
37 | cptr = malloc( length ); |
---|
38 | if ( cptr ) |
---|
39 | memset( cptr, '\0', length ); |
---|
40 | |
---|
41 | MSBUMP(malloc_calls, (uint32_t) -1); /* subtract off the malloc */ |
---|
42 | |
---|
43 | return cptr; |
---|
44 | } |
---|
45 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.