[fpc-pascal] memory aligning

David Pethes imcold at imcold.evilhosting.org
Mon Nov 5 22:28:33 CET 2007


Hi,

Micha Nelissen wrote:

>> function evk_malloc (size: longword): pointer;
>> const
>>   ALIGNMENT = 16;
>> var
>>   ptr: pointer;
>> begin
>>   ptr := getmem(size + ALIGNMENT);
>>   result := Align (ptr, ALIGNMENT);
>>   if result = ptr then
>>       pbyte(result) += 16;
> 
> Why not use ALIGNMENT here also?

Hah, I got stuck between using a constant and direct value... :) I 
should make it consistent. Thanks for reviewing and pointing this out.

> BTW, GetMem already returns 16 byte aligned blocks. If it does not, it's
> considered a bug.

I didn't know that, looks like I should reread the documentation. I need 
the address on which the block begins to be divisible with 16, though.

David




More information about the fpc-pascal mailing list