xcalloc

Allocates memory for an array of objects.

Library:LibC
Classification:Other
Service:Memory Management

Syntax

  #include <xmalloc.h> 
   
  void *xcalloc (
     size_t   n,   
     size_t   size);
  

Parameters

n

(IN) Specifies the number of objects.

size

(IN) Specifies the size (in bytes) of each object.

Return Values

Returns a pointer to the start of the allocated memory. If insufficient memory is available, exits and writes a “no memory available” message on stderr. If the value of the size parameter is 0, returns a pointer to one byte of memory.

Remarks

The xcalloc function calls the calloc function which initializes all the memory to binary zeroes.

A block of memory allocated using the xcalloc function should be freed using the xfree function.

See Also