![]() |
![]() |
![]() |
![]() |
![]() |
This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Control the extra checking for memory allocation
![]() |
The debug version of this function is declared in <malloc_g/malloc.h>. The debug version includes additional commands and settings that aren't in <malloc/malloc.h>. |
#include <malloc/malloc.h> int mallopt( int cmd, int value );
The debug version also supports the following (which the normal version ignores):
For more information about the commands and their possible values, see below.
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The mallopt() function controls memory allocation; the debug version also controls the extra checking of memory allocation.
You can set some of the variables by using environment variables, as listed below. This is an easy way to control the memory allocation, but the environment variables are checked only when your program starts.
For more information about memory allocation and debugging it, see the Heap Analysis: Making Memory Errors a Thing of the Past chapter of the Neutrino Programmer's Guide.
If value is 0, mallopt() returns the current arena size; if value is any other value, mallopt() returns the previous size.
If you're using the debug version of mallopt(), you can use the following options to control additional checks in the library:
The value argument can be:
The value argument can be:
The value argument can be:
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_EXIT | 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 |
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.
0 on success, or -1 if an error occurs (errno is set).
For MALLOC_ARENA_SIZE, if value is 0, mallopt() returns the current arena size; if value is any other value, mallopt() returns the previous size.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
calloc(), free(), mallinfo(), malloc(), realloc()
Heap Analysis: Making Memory Errors a Thing of the Past chapter of the Neutrino Programmer's Guide
![]() |
![]() |
![]() |
![]() |