httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cliff Woolley <jwool...@virginia.edu>
Subject Re: Apr array functions
Date Tue, 09 Nov 2004 01:50:29 GMT

Btw: didn't notice ahead of time that this discussion was on dev@httpd
instead of dev@apr.  Oh well.


On Mon, 8 Nov 2004, Cliff Woolley wrote:

> You don't have to remove elements to get at them... the array header
> structure is visible to the application, so it can just do
> arr->elts[index] and be done with it (insert bounds checking if
> necessary).

To be more precise, since arr->elts is a void pointer, you have to insert
a cast here.  But it doesn't have to be as complex looking as asking the
array structure how big each element is and explicitly multiplying.
Presumably the application code knows what actualy type the data stored in
the array is, and thus a cast and pointer arithmetic will do the job for
you.

((foo_t *)arr->elts)[index]

Or, even better:

foo_t *f = arr->elts;
f[index] ...

--Cliff

Mime
View raw message