source: rtems/cpukit/libcsupport/src/calloc.c @ 7660e8b3

4.115
Last change on this file since 7660e8b3 was 7660e8b3, checked in by Sebastian Huber <sebastian.huber@…>, on 07/23/13 at 11:32:58

Include missing <string.h>

  • Property mode set to 100644
File size: 823 bytes
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
26void *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.