[fpc-devel] cmem not aligning memory
Jonas Maebe
jonas.maebe at elis.ugent.be
Tue Apr 6 13:07:05 CEST 2010
On 06 Apr 2010, at 12:00, Michael Schnell wrote:
> 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 ?
Conforming to the cpu's alignment requirements.
> With many embedded CPUs alignment is
> forced to prevent runtime errors. With an X86 any alignment is allowed
> but performance is different
Vectors on x86 also require the memory to be aligned (unless you use
special instructions, but by default compilers will not do that since
that partially defeats the purpose of using vectors).
> 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,
No, calloc simply zeroes the allocated memory.
Jonas
More information about the fpc-devel
mailing list