Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 82780 invoked by uid 500); 27 Aug 2002 23:42:39 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 82764 invoked from network); 27 Aug 2002 23:42:37 -0000 Date: Tue, 27 Aug 2002 19:42:28 -0400 (EDT) From: Cliff Woolley X-X-Sender: root@deepthought.cs.virginia.edu To: "Gregory (Grisha) Trubetskoy" cc: dev@apr.apache.org Subject: Re: A question about rings. In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N On Tue, 27 Aug 2002, Gregory (Grisha) Trubetskoy wrote: > In other words, instead of > > #define APR_RING_SENTINEL(hp, elem, link) \ > (struct elem *)((char *)(hp) - APR_OFFSETOF(struct elem, link)) > > Why not: > > #define APR_RING_SENTINEL(hp, elem) \ > (struct elem *)(hp) > > It so happens that the APR_RING_ENTRY is always first in the element > structure, and so the offset is 0 which is why it works (and the macros > above yeld same result). But it seems to me that if the APR_RING_ENTRY > was't first, then the result of APR_RING_SENTINEL could be a pointer to > somewhere before beginning of head, or some place within head but before > APR_RING_HEAD, which could be some arbitrary and not necessarily constant > value. That's in fact exactly the point. The sentinel value is not really to be thought of as a pointer to anything in particular... it's just a magic number. A ring element structure can be set up so that each element can be on more than one ring at a time. In that case, each of the rings attached to any given head needs a unique sentinel value. So while it's true that this is hardly ever used and is optimized away, it's there just in case somebody wants to use it. Make more sense? --Cliff