Controlling the level of checking

The mallopt() function call allows extra checks to be enabled within the library.

The call to mallopt() requires that the application be aware that the additional checks are programmatically enabled. The other way to enable the various levels of checking is to use environment variables for each of the mallopt() options. Using environment variables lets you specify options that will be enabled from the time the program runs, as opposed to only when the code that triggers these options to be enabled (i.e. the mallopt() call) is reached. For certain programs that perform a lot of allocations before main(), setting options using mallopt() calls from main() or after that may be too late. In such cases, it's better to use environment variables.

The prototype of mallopt() is:

int mallopt ( int cmd, 
              int value );

The arguments are:

The command you want to use. The options used to enable additional checks in the library are:

We look at some of the other commands later in this chapter.

A value corresponding to the command used.

For more details, see the entry for mallopt() in the Neutrino C Library Reference.