calloc

Allocates memory for an array of objects.

Library:LibC
Classification:ANSI
Service:Memory Management

Syntax

  #include <stdlib.h> 
   
  void *calloc (
     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 or if the value of the size parameter is 0, returns NULL.

Remarks

The calloc function initializes all the memory to binary zeroes.

Memory allocation is not limited to 64 KB. The size parameter is 32 bits.

The calloc function calls the malloc function.

A block of memory allocated using the calloc function should be freed using the free function.

See Also