Alignment of objects returned by malloc() and operator new()
newsgroups at smartcontroller.com.au
Fri Dec 7 21:14:49 UTC 2007
Robert S. Grimes wrote:
> Chris Johns wrote:
>>Robert S. Grimes wrote:
>>>1. What are the alignment characteristics of memory returned by malloc()?
>>>2. What about operator new()?
>>>I need to allocate memory for the Partition Manager, which wants it
>>>allocated on a 4-byte boundary - need I do anything special?
>>The most portable way is to allocate 4 bytes more and then move the start address.
Moreover, you should allocate in multiples of 4 - so use /4 and %4 in
your memory calculation
Dr Angelo Fraietta
A.Eng, A.Mus.A, BA(Hons), Ph.D.
PO Box 859
Hamilton NSW 2303
There are those who seek knowledge for the sake of knowledge - that is
There are those who seek knowledge to be known by others - that is VANITY
There are those who seek knowledge in order to serve - that is LOVE
Bernard of Clairvaux (1090 - 1153)
More information about the users