malloc()

allocate space for objects 

Function


SYNOPSIS

#include <stdlib.h>

void *malloc(size_t size);


DESCRIPTION

The malloc() function allocates space for an object. malloc() returns a pointer to a block whose size is specified by size and whose value is indeterminate.


PARAMETERS

size 

Specifies the size of the allocated block of memory. If size is zero, a unique pointer to the heap is returned.


RETURN VALUES

The malloc() function returns a null pointer if there is insufficient memory.


CONFORMANCE

ANSI/ISO 9899-1990.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

The malloc() function allocates from a private heap. Do not mix with Win32 heap allocation functions. Memory allocated with malloc() should only be freed with free().

Unlike many UNIX platforms, the heap that is used by malloc(), calloc(), and realloc() is not guaranteed to be one contiguous piece of memory. Thus it is invalid to assume that all memory between two pointers returned by these functions is accessible, and it is invalid to compare pointers returned by these functions to determine the total size of the heap.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
calloc(), free(), memalign(), realloc(), valloc()


PTC MKS Toolkit 10.4 Documentation Build 39.