|
Boost : |
From: Dave Handley (dave.handley_at_[hidden])
Date: 2005-01-20 12:38:22
<snip on alignment>
Jonathan Wakely wrote:
> > memory is alignment with the type being allocated. Malloc and New are
> > guaranteed to return memory that is aligned for an object of that size
>
> Guaranteed to be aligned for _any_ type, isn't it ?
Any type that is not bigger than the memory size allocated. I'm
pretty sure that the ANSI requirement for malloc and new does not
require alignment to 8/16 byte blocks for memory allocations of a
single byte (for example). This means that, to be pedantic, a 1 byte
allocation is not guaranteed to be aligned for a double (for example).
However, since this is a silly example, for all practical purposes
you are correct. Also, some implementation may well guarantee
alignment for small allocations.
Nevertheless, my rather terse comment about being guaranteed to return
memory aligned for an object of that size was probably a bit too
terse, so thanks for the quotes and clarification.
Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk