[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Alignment of objects returned by malloc() and operator new()
- Date: Mon, 10 Dec 2007 14:05:31 -0600
- From: joel.sherrill at oarcorp.com (Joel Sherrill)
- Subject: Alignment of objects returned by malloc() and operator new()
FWIW the SuperCore heap has an aligned allocated
method that is NOT available through the malloc
family. Shouldn't be terribly difficult to
support, it just isn't published through that
API set.
--joel
Angelo Fraietta wrote:
> Robert S. Grimes wrote:
>
>> Chris Johns wrote:
>>
>>
>>> Robert S. Grimes wrote:
>>>
>>>
>>>
>>>> Quick questions
>>>>
>>>> 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
>
> Good luck
>