xmalloc.h File Reference

Brittle memory allocation routines. More...

#include <sys/types.h>

Go to the source code of this file.

Functions

void * xxmalloc (size_t nbytes)
 Allocate memory, or abort on failure.
char * xstrdup (const char *str)
 Duplicate string, or abort on failure.

Detailed Description

Brittle memory allocation routines.

These routines may be used in place of malloc and strdup. If they fail due to the (rare) possibility of heap exhaustion, they will abort by calling fatal with an appropriate error message. Thus, the caller of these routines need not continually check for a null pointer return.


Function Documentation

void* xxmalloc ( size_t  nbytes  ) 

Allocate memory, or abort on failure.

Parameters:
nbytes The amount of memory to allocate.
Returns:
On success, returns a valid pointer. On failure, aborts by calling fatal.
char* xstrdup ( const char *  str  ) 

Duplicate string, or abort on failure.

Parameters:
str The string to duplicate.
Returns:
On success, returns a valid pointer. On failure, aborts by calling fatal.
Generated on Sun Aug 14 20:55:54 2011 for cctools by  doxygen 1.6.3