Next: UNIX notes, Up: Notes
MP_NONEWDELETE
may have to be used a lot. Explicit references to
operator new
rather than new
are likely to result in compilation
errors, and the way that source level information is obtained for
operator delete
means that the resulting code will not be thread-safe.
It might also be an idea to provide an allocation class from which user-defined
memory allocators can be derived.
infohead
structure and then having an array of infohead
structures
from which to allocate new memory headers when a new one is required. This is
only necessary for Amiga shared libraries and Netware NLMs since UNIX and
Windows platforms allocate a new copy of the data section in a shared library or
DLL when it is opened by a new process.
__builtin_frame_address()
and __builtin_return_address()
that are
available when the library is compiled with gcc. However, they can
only traverse a number of stack frames at compile-time, not run-time so there is
a maximum number of stack frames that can be traversed at any one time. The
implementation depends on both of these builtin functions returning `NULL'
when the top of stack is reached. If this is not the case then this method
cannot be used or should only be used with a small number of fixed stack frames.
However, using backtrace()
from glibc is also supported as well.
__mp_compareaddrs()
so that it will improve the detection
of when to free memory allocations made by alloca()
and its related
functions. This will involve checking the common return addresses in the call
stacks instead of just checking them if the stack depth is the same. Also,
on systems that don't have full call stack traversal, the minimum number of
bytes that stack frames should differ by should be platform-dependent since the
current value is way too high.
__malloc_hook()
,
__realloc_hook()
and __free_hook()
in much the same way as for the
GNU C library.
__mp_printinfo()
function and add this
information to the profiling output file so that mprof can make use of
it.
memcpy()
and
memset()
to the existing memory allocation profiling facility. Also, add
options to mprof to write out files that can be used by chart drawing
software for a better visualisation of the first few profiling tables.
mallopt()
, mallinfo()
, memorymap()
,
mallocctl()
, mallocblksize()
and msize()
which are provided
in many other malloc libraries. These won't necessarily behave in exactly the
same way as existing implementations, but at least there won't be link errors
when compiling source code which uses them. Also, add support for setting as
many remaining options in __mp_setoption()
as possible and perhaps even
some options before the mpatrol library has been initialised.
mcheck()
and mprobe()
functions.
Perhaps also add an mpatrol tool to add compatibility with the GNU memusage
tool.
strlen()
and strcmp()
in much the same way as was done for
the memory operation functions. The only problem with this would be locale
support, but perhaps it might be easier just to assume the C locale to begin
with. Also need to have better detection of internal and free blocks when
displaying memory range errors.
memset()
, etc. These are defined as
wmemset()
, etc. and are now part of ANSI C. Also add wcsdup()
,
memdup()
and xmemdup()
as well as mempcpy()
and
memrchr()
.
malloc()
each time a write to the log file
occurs on some systems. Example code to do this was submitted by Alexander
Barton and this may well be incorporated into the library at some point in the
future2.
NDEBUG
is defined.
etext
, edata
and end
pointers that are set at run-time on
most UNIX systems. Need to properly implement chkr_check_exec()
.
__mp_memquery()
function.
sbrk
heap.
malloc()
and other related routines when the mpatrol
library is attempting to initialise itself.
MP_FAILURE()
. Should also add something similar to
xmalloc_set_program_name()
in order to show the program name when a
memory allocation fails. If the C++ operators fail to allocate memory in
libmpalloc then there should probably also be an exception thrown to mimic the
behaviour of libmpatrol, although this isn't a big issue since the program
should be completely recompiled to remove mpatrol debugging before a release.
In the same vein, perhaps there should be some sort of support for
set_new_handler()
in libmpalloc.
xmalloc()
which means that it will run unbearably slowly under
mpatrol4.
[1] There is now a library called libunwind that mpatrol can be built with to add support for stack traversal on various architectures and more will likely follow in the future. There is also a library called StackTrace written by Bjorn Reese which invokes a debugger to generate a stack traceback on certain UNIX platforms, although this method would be too slow for mpatrol to use.
[2] This code can be applied as an mpatrol library patch which can be downloaded from http://heanet.dl.sourceforge.net/sourceforge/mpatrol/mpatrol_patch1.tar.gz.
[3] And perhaps also make the mptools library threadsafe as well
[4] If you really really want this functionality then code to do this is available as an mpatrol library patch which can be downloaded from http://heanet.dl.sourceforge.net/sourceforge/mpatrol/mpatrol_patch4.tar.gz.