begin  quoting James G. Sack (jim) as of Sun, Oct 01, 2006 at 02:22:11PM -0700:
> Gabriel Sechan wrote:
[snip]
> > Instead of calling malloc, mwMalloc makes OS level calls to request the
> > memory itself (which is the same thing malloc usually does).  It then
> > uses #define to override the default malloc, so any file that includes
> > this file should use this malloc instead of the default one.

What are those calls? I didn't see 'em when I skimmed the code.

> Something like that would seem sensible, but in memwatch.c:893 (in V2.71)
>   mw = (mwData*) malloc( needed );
> this code is in
>   void* mwMalloc( size_t size, const char* file, int line) {
> 
> similarly, mwMalloc_() also calls malloc()
> 
> So it seems that memwatch does it via a wrapper around standard malloc.
> 
> But the sequence of defines, proto declarations, and code definitions
> puzzles me much. (As SS intimated,) it looks circular!

It must be that the #define is for code that uses mwMalloc, but it isn't
#defined in the code that declares and defines mwMalloc. That way, the
object file that defines mwMalloc uses the real malloc, and the .o file
that was compiled with the #include doesn't.

-- 
_ |\_
 \|

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to