From gstein@lyra.org Tue Jan 2 02:24:15 2001
Return-Path:
Mailing-List: contact dev-help@apr.apache.org; run by ezmlm
Delivered-To: mailing list dev@apr.apache.org
Received: (qmail 67383 invoked from network); 2 Jan 2001 02:24:15 -0000
Received: from kurgan.lyra.org (198.144.203.198)
by h31.sny.collab.net with SMTP; 2 Jan 2001 02:24:15 -0000
Received: (from gstein@localhost)
by kurgan.lyra.org (8.9.3/8.9.3) id SAA10663
for dev@apr.apache.org; Mon, 1 Jan 2001 18:29:06 -0800
X-Authentication-Warning: kurgan.lyra.org: gstein set sender to gstein@lyra.org using -f
Date: Mon, 1 Jan 2001 18:29:06 -0800
From: Greg Stein
To: dev@apr.apache.org
Subject: Re: cvs commit: apr/include apr_general.h
Message-ID: <20010101182906.G10567@lyra.org>
Mail-Followup-To: dev@apr.apache.org
References: <20010101174842.E10567@lyra.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.2i
In-Reply-To: ; from rbb@covalent.net on Mon, Jan 01, 2001 at 05:49:12PM -0800
X-URL: http://www.lyra.org/greg/
X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N
On Mon, Jan 01, 2001 at 05:49:12PM -0800, rbb@covalent.net 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/