On Mon, Jan 01, 2001 at 05:49:12PM -0800, [EMAIL PROTECTED] wrote: > > > > Log: > > > Add an APR_GET_POOL macro to get a pool from any APR type that has > > > a pool. This requires that ALL apr types put the pool as the first > > > field in their structure. > > > > Euh... this is dangerous as hell. Why do we need this? > > A) why is this dangerous at all?
Casting a pointer to something else, and then presuming that a pool is at the beginning of the structure, is just plain dangerous. The whole point of being incomplete is to hide their organization; that assumption shouldn't be made. > We do stuff like this all the time in > Apache. Whenever we get the pool from the request_rec, we are basically > doing the same thing. No. We just do r->pool. > The only difference is that we are getting it from > an incomplete type. And that is the whole problem. It is incomplete -- the caller can't possibly know the pool is at the start of the structure. > b) we need this so that we don't leak memory like a sieve. I committed a > use of this to the buckets code a few minutes ago. Then write apr_file_get_pool(). Not a cast and an assumption. Cheers, -g -- Greg Stein, http://www.lyra.org/
