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

M

MALLOC() Macro

The MALLOC macro is a platform-independent substitute for the C library routine malloc. It allocates size bytes from the requests's memory pool. The memory can be explicitly freed by a call to FREE. If the memory is not explicitly freed, it is automatically freed after processing of the current request has been completed. If pooled memory has been disabled in the configuration file with the built-in SAF pool-init , PERM_MALLOC and MALLOC both obtain their memory from the system heap. However, because memory allocated by MALLOC is automatically freed, it should not be shared between threads.

Memory allocated by MALLOC, in an initialization function when there is no request, is translated to a native malloc call on UNIX and Linux platforms.

If pooled memory has been disabled in the configuration file with the built-in SAF pool-init, PERM_MALLOC, and MALLOC both obtain their memory from the system heap.

Syntax

void *MALLOC(int size)

Return Values

A void pointer to a block of memory.

Parameters

int size is the number of bytes to allocate.

Example

/* Allocate 256 bytes for a name */
char *name;
name = (char *) MALLOC(256);

See Also

FREE() Macro, CALLOC() Macro, REALLOC() Macro, STRDUP() Macro, PERM_MALLOC() Macro