On Fri, 20 Oct 2000, Andres Kroonmaa wrote:
> On 20 Oct 2000, at 10:36, Alex Rousskov <rousskov@measurement-factory.com> wrote:
>
> > Just keep in mind that pointers/counters may need to be aligned on some
> > platforms. For example, a "struct { char buf[9] }" in an array may not
> > be aligned, and using its first bytes for a pointer or offset counter is
> > dangerous.
> >
> > Thus, if you use first bytes of a free object, you probably want to copy
> > the pointer into a local variable before de-referencing it. Not a big
> > deal, of course.
>
> well, I think we should be safe within pools, as poolCreate is passed
> obj size that should be suitably aligned and padded for use in arrays.
No. What is suitable for one object, may not be suitable for another.
Each "struct { char buf[9]; }" will consume 9 bytes in an array.
Hence, most of the objects of the above type will not be appropriately
aligned to stuff a pointer or even an integer in them.
> But for the safe side, we could forcibly round up obj size to a multiple
> of pointer. this should make us safely aligned to sizeof(pointer)
> With a list we can't pool smaller objects than sizeof pointer anyway.
Won't help if my example above is correct.
Alex.
Received on Fri Oct 20 2000 - 12:52:09 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:52 MST