On 5/16/11 8:49 AM, Tor Didriksen wrote:
>>> + /*
>>> >> + Reserves space for array elements.
>>> >> + Copies over existing elements, in case we are re-expanding the
> array.
>>> >> +
>>> >> + @param n number of elements.
>>> >> + @retval true if out-of-memory, false otherwise.
>>> >> + */
>>> >> + bool reserve(size_t n)
>>> >> + {
>>> >> + if (n<= m_capacity)
>>> >> + return false;
>>> >> +
>>> >> + void *mem= alloc_root(m_root, n * element_size());
>>> >>
>> >
>> > Hum, what about alignment? Should we care? If not, just add a note.
>
> We use alloc_root() all over the place, and I see no alignment arguments
> anywhere.
> We must assume that alloc_root() has the same poperty as malloc():
> return a pointer to the allocated memory, which is suitably aligned for any
> kind of variable
>
My concern is about alignment of the subsequent elements of the array. I
think we can rely on the compiler to add padding after the last member
to ensure that each element in a array of the type is aligned.
Regards,
Davi