List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:May 16 2011 4:04pm
Subject:Re: bzr commit into mysql-trunk branch (tor.didriksen:3083) Bug#12552221
View as plain text  
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
Thread
bzr commit into mysql-trunk branch (tor.didriksen:3083) Bug#12552221Tor Didriksen13 May
  • Re: bzr commit into mysql-trunk branch (tor.didriksen:3083) Bug#12552221Davi Arnaut13 May
    • Re: bzr commit into mysql-trunk branch (tor.didriksen:3083) Bug#12552221Tor Didriksen16 May
      • Re: bzr commit into mysql-trunk branch (tor.didriksen:3083) Bug#12552221Davi Arnaut16 May
        • Re: bzr commit into mysql-trunk branch (tor.didriksen:3083) Bug#12552221Tor Didriksen18 May