From: "Christopher R. Hertel" <crh@NTS.Umn.EDU> Message-Id: <199805061808.NAA05254@unet.unet.umn.edu> Subject: Re: free pointer To: tridge@samba.anu.edu.au Date: Wed, 6 May 1998 13:08:14 -0500 (CDT) In-Reply-To: <19980506025029Z12600111-20526+4004@samba.anu.edu.au> from "Andrew Tridgell" at May 6, 98 12:52:38 pm
>
> Hi Chris,
Hi Andrew,
> You use a pointer to "free" in the new mangled cache stuff. You can't
> do that. free() could easily be a macro on some systems.
Ahh. Good point. Quick fix similar to the one you outlined below.
> anyway, a quick fix would be to use a ubiqx_free function that calls
> free. Preferably inside a module that includes the standard Samba
> includes so it can benefit from -DMEM_MAN if defined.
I would add it to mangle.c, just below the comparison function.
> Maybe a better fix is to not pass a free function at all to ubiqx init
> calls. maybe ubiqx should really clean up its own memory via some sort
> of ubi_Destroy() call ?
No good. The tree and list modules don't know anything about how the
memory is being managed. It may be a free list, or a chunk of a large
pre-allocated buffer, or something else. I originally wrote this stuff to
work on an Amiga and assumed that people might want to use the low-level
OS memory management calls in the exec.library.
The cache is built on top of the trees, so I put a pointer to a free
function into the cache header. I let the calling code allocate the
needed memory, but the cache may need to free an entry at any time, thus
the call-back.
So, the *right* way to do it is as you suggest: I'll check in a new
mangle.c with a cache_free_entry() function *of the correct type* as soon
as it's tested.
Chris -)-----
-- Christopher R. Hertel -)----- University of Minnesota crh@nts.umn.edu Networking and Telecommunications Services