Boost logo

Boost :

Subject: Re: [boost] Boost.Align review begins today
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-04-17 16:44:50

On Thu, Apr 17, 2014 at 10:57 PM, Glen Fernandes
<glen.fernandes_at_[hidden]> wrote:
> 2. The generic (non-platform specific) aligned_alloc implementation
> was changed to be more conservative in memory allocations. In addition
> to allocating alignment-1 extra bytes (instead of alignment extra
> bytes), it uses std::memcpy to write or read the original pointer
> (instead of rounding up alignment to alignof(void*) bytes).

I'm not sure this is a good idea. Given that pointer size is 4 or 8
bytes (with the same alignment) on modern platforms and that the
native malloc alignment is also 8 or 16 (on 32 and 64-bit platforms)
already, you don't save anything. No sane memory allocator will allow
you to allocate 1 byte at alignment 1 for example, it'll be 8 bytes at
least. OTOH, I've seen cases when the compiler was not able to
optimize away memcpy. I think rounding up the alignment was the right
thing to do.

Boost list run by bdawes at, gregod at, cpdaniel at, john at