Btw: didn't notice ahead of time that this discussion was on [EMAIL PROTECTED]
instead of [EMAIL PROTECTED]  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

Reply via email to