Slice allocator alignment



Hi,

Looking through the slice allocator, I see that it requests blocks
from posix_memalign that are aligned to page boundaries. Can I then
assume the following?

   For a type T, if T is required to be aligned to A=2^i byte
boundaries, and is of size S=j*A, then g_slice_new(T) will always
returned correctly aligned memory (i.e, g_slice_new(T)^(A-1) == 0)

A and S are less than a page size, of course. I'm also aware that
large memory requests are forwarded to malloc rather than
posix_memalign, so alignment is not guaranteed there. But I only need
to allocate individual blocks. Specifically, I need 16 byte alignment.
I think this assumption is valid in a basic fixed-size pool allocator,
so long as the pool itself is aligned, but I'm not sure about all this
magazine stuff in the slice allocator.

Thanks,
Scott


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]