[fpc-devel] cmem not aligning memory
Michalis Kamburelis
michalis.kambi at gmail.com
Sat Apr 3 18:46:12 CEST 2010
Marco van de Voort wrote:
> In our previous episode, Jonas Maebe said:
>>> Or do we have to allocate more bytes for blocks that are a multiple of 8?
>> FPC's default memory manager even guarantees 16 byte alignment (for vectors).
>
> So a possible solution is to allocate 16-sizeof(ptruint) bytes more?
>
> for 32-bit that would mean:
>
> <12 bytes slack><size><data>
>
Note that fftw_getmem and fftw_freemem (packages/fftw/src/fftw_s.pas)
already contain the code to allocate always aligned pointer. (They
allocate 15 bytes more for 16-bytes aligmnment, and store the value of
original unaligned pointer to pass it to free.)
One could use these as a workaround, to get aligned pointers from any
GetMem/FreeMem implementation.
Michalis
More information about the fpc-devel
mailing list