Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualHodgman

Posted 01 November 2012 - 03:49 AM

Can you store it as a T* ? Doing so would make indexing the array easier.

When manually allocating memory for a type, you need to ensure that your allocation is naturally aligned for that type. The easiest solution is to just ensure that all allocations are 16-byte aligned as a worst-case value, but that depends on the platform... C++11 added alignof to help here.

There's also platform/OS-specific options besides new/malloc, such as _aligned_malloc.

#1Hodgman

Posted 31 October 2012 - 11:08 PM

Can you store it as a T* ? Doing so would make indexing the array easier.

When manually allocating memory for a type, you need to ensure that your allocation is naturally aligned for that type. The easiest solution is to just ensure that all allocations are 16-byte aligned as a worst-case value, but that depends on the platform... C++11 added alignof to help here.
There's also platform/OS-specific options here, such as _aligned_malloc.

PARTNERS