NCL Home > Documentation > HLUs > API

NhlMalloc

NhlMalloc, NhlRealloc, NhlFree

No corresponding Fortran routines.

Memory allocation functions.


Synopsis

#include <ncarg/hlu/hlu.h>

void *NhlMalloc(
		unsigned int	size
		)

void *NhlRealloc(
		void		*data,
		unsigned int	size
		)

NhlErrorTypes NhlFree(
		void		*data
		)

Arguments

size (input)
Specifies the size of the memory to allocate.
data (input)
Specifies a pointer to memory previously returned from NhlMalloc or NhlRealloc.

Types

Type name:		NhlTErrorTypes
Definition:
typedef enum _NhlErrType{
	NhlFATAL	= -4,	/* "FATAL"	*/
	NhlWARNING	= -3,	/* "WARNING"	*/
	NhlINFO		= -2,	/* "INFO"	*/
	NhlNOERROR	= -1	/* "NOERROR"	*/
} NhlErrorTypes;

Description

These functions behave like the stdlib functions malloc, realloc and free.

NhlMalloc returns a pointer to a block of memory of at least size bytes. The argument to NhlFree is a pointer to a block previously allocated with NhlMalloc. If NhlMalloc is called with a size of 0, it returns NULL.

NhlFree frees the memory pointed at by data so the memory can be re-used. NhlFree must be called on all memory allocated by the HLU library on behalf of the user. This includes all arrays retrieved from objects using NhlGetValues. If NhlFree is called with a NULL pointer, it doesn't work.

NhlRealloc changes the size of the block of memory pointed at by data. It may extend the current block or allocate another block, copy the contents pointed at by data to the new location, and then free the old block. It returns a pointer to the new block. If data is NULL, NhlRealloc behaves like NhlMalloc.


Return values

NhlMalloc
returns a pointer to a block of memory, or NULL if a size 0 is specified or if it can't allocate the memory.
NhlRealloc
returns a pointer to a block of memory, or NULL if a size 0 is specified or if it can't allocate the memory.
NhlFree
returns a value of NhlErrorTypes:
NhlNOERROR if there is no error, or NhlWARNING if there is a detectable error.