Next: Environment, Previous: Tutorial, Up: Top
The mpatrol library contains implementations of dynamic memory allocation
functions for C and C++ suitable for tracing and debugging. The library is
intended to be used without requiring any changes to existing user source code
except the inclusion of the mpatrol.h header file, although additional
functions are supplied for extra tracing and control. Note that the current
version of the mpatrol library is contained in the MPATROL_VERSION
preprocessor macro.
All of the function definitions in mpatrol.h can be disabled by defining
the NDEBUG
preprocessor macro, which is the same macro used to control
the behaviour of the assert()
function. If NDEBUG
is defined then
no macro redefinition of functions will take place and all special mpatrol
library functions will evaluate to empty statements. The mpalloc.h
header file will also be included in this case. It is intended that the
NDEBUG
preprocessor macro be defined in release builds.
The MP_MALLOC()
family of functions that are defined in mpalloc.h
are also defined in mpatrol.h when NDEBUG
is not defined. The
mpatrol versions of these functions contain more debugging information than the
mpalloc versions do, but they do not call the allocation failure handler when no
more memory is available (they cause the `OUTMEM' error message to be given
instead).