[Previous] [Contents] [Index] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

mallopt()

Control the extra checking for memory allocation

Synopsis:

#include <malloc.h>

int mallopt( int cmd,
             int value );

Arguments:

cmd
Options used to enable additional checks in the library.

See the Description section for more details.

value
A value corresponding to the command; see below:

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The mallopt() function controls the extra checking of memory allocation.

Options used to enable additional checks in the library include:

MALLOC_CKACCESS
Turn on (or off) boundary checking for memory and string operations.
Environment variable: MALLOC_CKACCESS.

The value argument can be:

MALLOC_FILLAREA
Turn on (or off) fill-area boundary checking.
Environment variable: MALLOC_FILLAREA.

The value argument can be:

MALLOC_CKCHAIN
Enable (or disable) full-chain checking. For each of the above options, an integer argument value of one indicates that the given type of checking should be enabled from that point onward.
Environment variable: MALLOC_CKCHAIN.

The value argument can be:

MALLOC_VERIFY
Perform a chain check. If an error is found, perform error handling. The value argument is currently ignored; pass 1 for it.
MALLOC_FATAL
Specify the malloc fatal handler.
Environment variable: MALLOC_FATAL.

Use one of the following for the value arguments:

Symbolic name Value Description
M_HANDLE_IGNORE 0 Cause the program to dump a core file.
M_HANDLE_ABORT 1 Terminate execution with a call to abort()
M_HANDLE_ABORT 2 Exit immediately
M_HANDLE_CORE 3 Cause the program to dump a core file
M_HANDLE_SIGNAL 4 Stop the program when this error occurs
MALLOC_WARN
Specify the malloc warning handler. The values are similar to MALLOC_FATAL; see above.
Environment variable: MALLOC_WARN.

For details, see "Controlling the level of checking" in the Heap Analysis: Making Memory Errors a Thing of the Past chapter of the Neutrino Programmer's Guide.


Note: See the Heap Analysis: Making Memory Errors a Thing of the Past chapter of the Neutrino Programmer's Guide.

Returns:

0 on success, or -1 if an error occurs (errno is set).

Classification:

QNX Neutrino

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

See also:

calloc(), free(), mallinfo(), malloc(), realloc()

Heap Analysis: Making Memory Errors a Thing of the Past chapter of the Neutrino Programmer's Guide


[Previous] [Contents] [Index] [Next]