Sun Java System Web Server 7.0 Update 3 NSAPI Developer's Guide

REALLOC() Macro

The REALLOC macro is a platform-independent substitute for the C library routine realloc. This macro changes the size of a specified memory block that was originally created by MALLOC, CALLOC, or STRDUP. The contents of the object remains unchanged up to the lesser of the old and new sizes. If the new size is larger, the new space is uninitialized.


Caution – Caution –

Calling REALLOC for a block that was allocated with PERM_MALLOC, PERM_CALLOC, or PERM_STRDUP will not work.


Syntax

void *REALLOC(void *ptr, int size);

Return Values

A pointer to the new space if the request is satisfied.

Parameters

void *ptr is a (void *) pointer to a block of memory. If the pointer is not the one created by MALLOC, CALLOC, or STRDUP, the behavior is undefined.

int size is the number of bytes to allocate.

Example

char *name;
name = (char *) MALLOC(256);
if (NotBigEnough())    
    name = (char *) REALLOC(name, 512);

See Also

CALLOC() Macro, MALLOC() Macro, FREE() Macro, STRDUP() Macro, PERM_REALLOC() Macro