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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [libiberty/] [calloc.c] - Blame information for rev 1181

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

Line No. Rev Author Line
1 1181 sfurman
/* calloc -- allocate memory which has been initialized to zero.
2
   This function is in the public domain. */
3
 
4
/*
5
 
6
@deftypefn Supplemental void* calloc (size_t @var{nelem}, size_t @var{elsize})
7
 
8
Uses @code{malloc} to allocate storage for @var{nelem} objects of
9
@var{elsize} bytes each, then zeros the memory.
10
 
11
@end deftypefn
12
 
13
*/
14
 
15
#include "ansidecl.h"
16
#include "libiberty.h"
17
 
18
#ifdef ANSI_PROTOTYPES
19
#include <stddef.h>
20
#else
21
#define size_t unsigned long
22
#endif
23
 
24
/* For systems with larger pointers than ints, this must be declared.  */
25
PTR malloc PARAMS ((size_t));
26
 
27
PTR
28
calloc (nelem, elsize)
29
  size_t nelem, elsize;
30
{
31
  register PTR ptr;
32
 
33
  if (nelem == 0 || elsize == 0)
34
    nelem = elsize = 1;
35
 
36
  ptr = malloc (nelem * elsize);
37
  if (ptr) bzero (ptr, nelem * elsize);
38
 
39
  return ptr;
40
}

powered by: WebSVN 2.1.0

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