realloc()

change size of memory block 

Function


SYNOPSIS

#include <stdlib.h>

void *realloc(void *ptr, size_t size);


DESCRIPTION

The realloc() function changes the size of the object pointed to by ptr to the size specified by size, and returns a pointer to the possibly moved block. The contents are unchanged up to the lesser of the new and old sizes. If ptr is null, realloc() behaves like malloc() for the specified size. If size is zero (0) and ptr is not a null pointer, the object pointed to is freed.


PARAMETERS

ptr 

Points to a memory block.

size 

Specifies the new size of the memory block.


RETURN VALUES

The realloc() function returns a null pointer if no memory is available. When realloc() returns null, the block pointed to by ptr is left intact. If size is zero (0), a unique pointer to the area is returned.


CONFORMANCE

ANSI/ISO 9899-1990.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

The realloc() function allocates from a private heap. Do not mix with Win32 heap allocation functions. Memory allocated with realloc() 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(), malloc(), memalign(), valloc()


PTC MKS Toolkit 10.4 Documentation Build 39.