httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Stein <>
Subject Re: palloc without a pool
Date Wed, 08 Sep 1999 11:15:23 GMT
Ryan Bloom wrote:
> > >   Allor ap_palloc to work without a pool.  Basically, this just uses malloc.
> > >   This also sets us up to allow multiple allocation methods in the same program.
> >
> > bleh.
> >
> > if you're going to use malloc like this, then just use malloc.  otherwise
> > you're paying a conditional test on every call to palloc.  not to mention
> > that there's no free() function... so you have to use free() eventually
> > anyhow, which seems to destroy the abstraction.
> Actually, I will be putting free in at some point.  I haven't gotten to it
> yet.  Currently, I can't use malloc, because I am having APR do all of the
> memory allocation.  That can change pretty easily, but that's they way it
> works right now.  So, the choice becomes calling ap_palloc for any memory
> allocation, using any technique, and letting ap_palloc figure out the
> right way to do it, or having multiple memory allocation routines.  For
> right now, ap_palloc does all allocation.  If we want that to change, it
> can change after I finish what I am currently working on.

If ap_palloc() can take on arbitrary schemes and one of those includes a
bare malloc(), then doesn't that imply that we must always call a free?
(because we don't know of the ap_palloc used a pool or not)  In other
words, just what Dean said: the abstraction seems to be destroyed.

I'm in favor of Dean's suggestion: don't use a free. ap_palloc() always
registers a cleanup for the memory item (where the memory came from).

*If* you can free an item and *unregister* the cleanup, then sure... a
free *could* make sense. However, I'd rather say "screw that complexity"
and make people run the cleanups if they need to free stuff. Having
pools *and* a free function would just be too annoying. People would
always ask "do I have to free this here?"


Greg Stein,

View raw message