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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [libiberty/] [calloc.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
/* calloc -- allocate memory which has been initialized to zero.
2
   This function is in the public domain. */
3
 
4
#include "ansidecl.h"
5
#include "libiberty.h"
6
 
7
#ifdef ANSI_PROTOTYPES
8
#include <stddef.h>
9
#else
10
#define size_t unsigned long
11
#endif
12
 
13
/* For systems with larger pointers than ints, this must be declared.  */
14
PTR malloc PARAMS ((size_t));
15
 
16
PTR
17
calloc (nelem, elsize)
18
  size_t nelem, elsize;
19
{
20
  register PTR ptr;
21
 
22
  if (nelem == 0 || elsize == 0)
23
    nelem = elsize = 1;
24
 
25
  ptr = malloc (nelem * elsize);
26
  if (ptr) bzero (ptr, nelem * elsize);
27
 
28
  return ptr;
29
}

powered by: WebSVN 2.1.0

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