source: rtems/cpukit/libcsupport/src/calloc.c @ 92119ed

4.115
Last change on this file since 92119ed was 346725cc, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/30/09 at 08:20:32

Rework autoconf defines.

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