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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [libiberty/] [calloc.c] - Blame information for rev 258

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

Line No. Rev Author Line
1 24 jeremybenn
/* 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 <stddef.h>
17
 
18
/* For systems with larger pointers than ints, this must be declared.  */
19
PTR malloc (size_t);
20
void bzero (PTR, size_t);
21
 
22
PTR
23
calloc (size_t nelem, size_t elsize)
24
{
25
  register PTR ptr;
26
 
27
  if (nelem == 0 || elsize == 0)
28
    nelem = elsize = 1;
29
 
30
  ptr = malloc (nelem * elsize);
31
  if (ptr) bzero (ptr, nelem * elsize);
32
 
33
  return ptr;
34
}

powered by: WebSVN 2.1.0

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