Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)
malloc(3) Guardian Native C Library Calls Reference Manual
NAME
malloc - Allocates memory
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRESRL
G-series native OSS processes: /G/system/sysnn/zcresrl
H-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCREDLL
H-series OSS processes: /G/system/zdllnnn/zcredll
SYNOPSIS
#include <sys/types.h>
#include <stdlib.h>
void ∗∗malloc(
size_t size);
PARAMETERS
size Specifies the number of bytes of memory to be allocated.
DESCRIPTION
The malloc() and free() functions provide a simple, general purpose memory allocation pack-
age.
The malloc() function returns a pointer to a block of memory of at least the number of bytes
specified by the size parameter. The block is aligned so that it can be used for any type of data.
If the size parameter is 0 (zero), the function returns a null pointer.
RETURN VALUES
This allocation function returns a pointer to space suitably aligned for storage of any type of
object. Cast the pointer to the type pointer-to-element before using it.
The malloc() function returns a null pointer if there is no available memory or if the memory
area has been corrupted by storing outside the bounds of a block. When this happens, the block
pointed to by the pointer parameter could be destroyed.
ERRORS
If any of the following conditions occurs, the function sets errno to the corresponding value:
[ENOMEM] There is not enough storage memory in the system.
RELATED INFORMATION
Functions: calloc(3), free(3), getpagesize(3), malloc_pages(3), realloc(3), valloc(3).
STANDARDS CONFORMANCE
The POSIX standards leave some features to the implementing vendor to define. In the HP imple-
mentation, the malloc() function returns a null pointer if the size parameter is 0 (zero).
4−40 Hewlett-Packard Company 527192-005