[fpc-devel] cmem not aligning memory

Michael Schnell mschnell at lumino.de
Tue Apr 6 12:00:34 CEST 2010

On 04/03/2010 02:12 PM, Jonas Maebe wrote:
> From Linux' malloc man page:
> For calloc() and malloc(), the value returned is a pointer to the allo-
> cated memory, which is suitably aligned for any kind of variable, or
> NULL if the request fails.
Hmm. What does "suitable" mean ? With many embedded CPUs alignment is
forced to prevent runtime errors. With an X86 any alignment is allowed
but performance is different Of course for Integers and Pointers  Dword
alignment (or QWord for 64 Bit systems) is appropriate (and supposedly
provided by malloc. But with Vectors (and long Reals) more strict
alignment might be faster. malloc() does not handle this. The C library
provides calloc() for this purpose, but I don't know how this exactly
works. I suppose it is implementation-depending.


More information about the fpc-devel mailing list