Mail Archives: djgpp-workers/2003/03/16/13:18:02
CBFalconer wrote:
>
... snip ...
>
> Is everybody talking about what I have attached (a zipped htm
> file). If so, I think mallinfo and mallocmap can be trivially
> implemented without changing nmalloc. mallocmap can thus ignore
> the level parameter. malloc_debug is harder, and probably needs
> the malloc hooks, which are not trivially implemented without
> changes, unless a different malloc package is linked using the
> alternative names and an interception package is loaded.
>
> Actually, without NDEBUG set, the internal names are redefined to
> be malloc, free, and realloc at compilation time. By changing
> this one definition to redefine as _malloc, _free, and _realloc
> there can be a 10 line generalized package, holding:
>
> void *malloc(size_t sz) {return _malloc(sz);}
>
> etc. and it might cost nothing if defined as inline. That would
> make inserting the hooks trivial, and nothing existing need be
> changed. The magic numbers in the malloc-hooks documentation
> would have to go - they are returned by the existing (in nmalloc)
> _sysquery call. Also nmalloc does not record a duplicate copy of
> block size - I had similar provisions earlier but they adversely
> affect the overhead for 8 byte alignment and people were worried
> about that when I started this project.
>
> ------------------------------------------------------------------
> Name: malldbg.zip
> malldbg.zip Type: Zip Compressed Data (application/x-zip-compressed)
> Encoding: base64
Nobody has confirmed or denied that the above describes everything
wanted. At any rate I have added some defines so that:
gcc -DNDEBUG -DHOOKABLE -o hookmem.o -c nmalloc.c
generates a module with malloc, free, realloc renamed to _malloc,
_free, and _realloc, and includes the following .h file:
/* -------- hookmem.h ----------- */
#ifndef hookmem_h
#define hookmem_h
#include <stddef.h>
void *_malloc(size_t sz);
void _free(void *ptr);
void *_realloc(void *ptr, size_t sz);
#endif
/* -------- hookmem.h ----------- */
What I don't see in the htm file I posted before is any process of
setting those hooks described. Nor do I find any libc/malloc.h on
my system. I do find include/malloc.h, which simply includes
stdlib.h.
--
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
- Raw text -