Next: Installation, Previous: Overview, Up: Top
An overall list of features contained in the mpatrol library is given below. This is not intended to be exhaustive since the best way to see what the library does is to read the documentation and try it out.
malloc()
| ANSI | Allocates memory.
|
calloc()
| ANSI | Allocates zero-filled memory.
|
memalign()
| UNIX | Allocates memory with a specified alignment.
|
valloc()
| UNIX | Allocates page-aligned memory.
|
pvalloc()
| UNIX | Allocates a number of pages.
|
alloca()
| old | Allocates temporary memory.
|
strdup()
| UNIX | Duplicates a string.
|
strndup()
| old | Duplicates a string with a maximum length.
|
strsave()
| old | Duplicates a string.
|
strnsave()
| old | Duplicates a string with a maximum length.
|
strdupa()
| old | Duplicates a string.
|
strndupa()
| old | Duplicates a string with a maximum length.
|
realloc()
| ANSI | Resizes memory.
|
reallocf()
| BSD | Resizes memory and frees on failure.
|
recalloc()
| old | Resizes memory allocated by calloc() .
|
expand()
| old | Resizes memory but does not relocate it.
|
free()
| ANSI | Frees memory.
|
cfree()
| old | Frees memory allocated by calloc() .
|
dealloca()
| new | Explicitly frees temporary memory.
|
xmalloc()
| Allocates memory without failure.
|
xcalloc()
| Allocates zero-filled memory without failure.
|
xstrdup()
| Duplicates a string without failure.
|
xrealloc()
| Resizes memory without failure.
|
xfree()
| Frees memory.
|
MP_MALLOC()
| Allocates memory without failure.
|
MP_CALLOC()
| Allocates zero-filled memory without failure.
|
MP_STRDUP()
| Duplicates a string without failure.
|
MP_REALLOC()
| Resizes memory without failure.
|
MP_FREE()
| Frees memory.
|
MP_FAILURE()
| Sets the allocation failure handler.
|
operator new
| Allocates memory.
|
operator new[]
| Allocates memory for an array.
|
operator delete
| Frees memory.
|
operator delete[]
| Frees memory allocated by operator new[] .
|
memset()
| ANSI | Fills memory with a specific byte.
|
bzero()
| UNIX | Fills memory with the zero byte.
|
memccpy()
| UNIX | Copies memory up to a specific byte.
|
memcpy()
| ANSI | Copies non-overlapping memory.
|
memmove()
| ANSI | Copies possibly-overlapping memory.
|
bcopy()
| UNIX | Copies possibly-overlapping memory.
|
memcmp()
| ANSI | Compares two blocks of memory.
|
bcmp()
| UNIX | Compares two blocks of memory.
|
memchr()
| ANSI | Searches memory for a specific byte.
|
memmem()
| UNIX | Searches memory for specific bytes.
|
set_new_handler()
.
mmap()
function can optionally be used to allocate
user memory instead of the sbrk()
function, but only if the system
supports it. If mmap()
is supported then internal mpatrol library memory
is normally allocated with this function in order to segregate it from user
memory but this behaviour can be swapped around.
malloc()
without requiring the inclusion of mpatrol.h, versions of the UNIX
functions brk()
and sbrk()
are provided for compatibility with
certain libraries. These should not be called by user code as they have
only limited functionality.
calloc()
or
recalloc()
functions will be pre-filled with a non-zero value in order to
catch out programs that wrongly assume that all newly-allocated memory is
zeroed. This value can be modified at run-time.
alloca()
, strdupa()
and strndupa()
functions are
implemented so that the temporary stack-based allocations that they would
normally make are now temporary heap-based allocations that can be traced by
mpatrol. Such allocations will be implicitly freed when the function that
allocated them returns, but a function also exists to explicitly free them as
well.
memset()
or memcpy()
)
have their arguments checked to ensure that they do not pass null pointers or
attempt to read or write memory straddling the boundary of a previously
allocated memory block, although an option exists to turn such an error into a
warning so that the operation can still be performed. Tracing from all such
functions can also optionally be written to the log file.
errno
is set to ENOMEM
if memory cannot be allocated, except for
the ANSI C++ operators which throw the std::bad_alloc
exception instead.
operator new[]
is not freed with
free()
for example.
NDEBUG
preprocessor macro, which also
disables the effect of calling any mpatrol library function.