cctools
|
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. More... | |
char * | xxstrdup (const char *str) |
Duplicate string, or abort on failure. More... | |
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.
void* xxmalloc | ( | size_t | nbytes | ) |
Allocate memory, or abort on failure.
nbytes | The amount of memory to allocate. |
char* xxstrdup | ( | const char * | str | ) |
Duplicate string, or abort on failure.
str | The string to duplicate. |