On Wed, Apr 13, 2011 at 2:56 PM, kevin diggs <diggskevin38@xxxxxxxxx> wrote: > Hi, > > On Wed, Apr 13, 2011 at 2:26 PM, Andrew Bell <andrew.bell.ia@xxxxxxxxx> wrote: >> >> malloc() will return memory on a boundary suitable for any type. If >> some types must be, say, 8-byte aligned, malloc will return memory >> that is 8-byte aligned. This of course satisfies types that are >> 4-byte, 2-byte and non-aligned. >> >> Your example code will end up breaking on some systems. >> > Even if it doesn't break it will likely incur a performance penalty > from unaligned accesses, right? I don't know if "likely" is the proper word here. On some architectures that don't _require_ specific alignment, I believe that access is slower when reads/writes occur from/to locations not on natural boundaries for the data type. -- Andrew Bell andrew.bell.ia@xxxxxxxxx