I was just wondering if there is a way to specify in Visual C++ that a
memory allocation
be double quadword aligned.

Any help is appreciated.

Thank you.

Re: memory allocation by Mark

Mark
Thu Jul 26 19:01:38 CDT 2007

Maybe look into _aligned_malloc()

http://msdn2.microsoft.com/en-us/library/8z34s9c6(VS.80).aspx

Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
<mike7411@gmail.com> wrote in message
news:1185488572.267304.241070@d55g2000hsg.googlegroups.com...
>I was just wondering if there is a way to specify in Visual C++ that a
> memory allocation
> be double quadword aligned.
>
> Any help is appreciated.
>
> Thank you.
>



Re: memory allocation by Alex

Alex
Fri Jul 27 05:41:25 CDT 2007

<mike7411@gmail.com> wrote:
> I was just wondering if there is a way to specify in
> Visual C++ that a
> memory allocation be double quadword aligned.

In addition to Mark's reply, if you need to align stack
allocation, then there is `__declspec(align( # ))'
specifier.

Alex


Re: memory allocation by Tim

Tim
Fri Jul 27 23:42:48 CDT 2007

"mike7411@gmail.com" <mike7411@gmail.com> wrote:
>
>I was just wondering if there is a way to specify in Visual C++ that a
>memory allocation
>be double quadword aligned.

You can always do arbitrary alignment yourself. To get 16-byte alignment,
just allocate a block 15 bytes larger than you need and round the pointer
up to the closest 16-byte alignment.

Just remember to undo the offset before freeing.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Re: memory allocation by Alex

Alex
Sat Jul 28 05:31:02 CDT 2007

"Tim Roberts" wrote:
> You can always do arbitrary alignment yourself. To get
> 16-byte alignment,
> just allocate a block 15 bytes larger than you need and
> round the pointer
> up to the closest 16-byte alignment.
>
> Just remember to undo the offset before freeing.

Yes, this is what `_aligned_malloc' actually does.

Alex