httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject memory allocation (was Re: Why bother with APR?)
Date Tue, 07 Sep 1999 23:00:19 GMT
so i'm thinking that it may not be possible to decide ahead of time what
type of memory allocation should be associated with a particular pool.
that is to say -- some users of a pool may want palloc-style allocation,
which isn't freed until pool destruction, and other users may want
malloc/free style which can be freed at will. 

there's two reasons i'm thinking along these lines -- the first is that
some users of a pool may be a cache, and could be hidden behind a library
interface.  the second reason is that i don't like lots of conditionals ;) 

i think of a pool as really a place to store cleanups.  in essence, a pool
could just be a list of cleanups. 

then ap_palloc() would register a cleanup the first time it is used. 

and ap_malloc() could register a cleanup for the list of malloc/free
allocations.

and ap_shmalloc() could register a cleanup for the shared mem
allocations... 

this way the same pool can be used for any combination of the three types
of allocations (and other allocations) without knowing ahead of time what
style of pool it is. 

Dean



Mime
View raw message