Message-ID: <3E74B558.3629CBA9@yahoo.com> Date: Sun, 16 Mar 2003 12:33:12 -0500 From: CBFalconer Organization: Ched Research X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: djgpp-workers AT delorie DOT com Subject: Re: nmalloc revisited References: <200303141601 DOT RAA26911 AT lws256 DOT lu DOT erisoft DOT se> <3E721051 DOT 645AA67D AT yahoo DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com 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 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. USE worldnet address!