So going over the new DirectXMath and loving how it has better documentation then the old versions, but anyways.
It makes a note on many of its targets need to have aligned memory blocks, but that throws me for a loop because I don't know of a way to declare an aligned memory block other than _aligned_malloc(...).
Also I never really thought about it, but in the documentation it goes over the difference between malloc and new as new calls a constructor so not to embed them in classes without overriding the new function to properly allocate these members with _aligned_malloc(...)
So this raises a couple questions for me about new. Firstly, is their an actual constructor call for value type members? Such that malloc() is better to call large fields of data for rather than new char[..]?
When you override new how do you do this for a class if you want alignment? If it's a 20 byte class do you simply ask for 20 bytes from malloc and return a casted pointer like
class Foo
{
static Foo* operator new(size_t size)
{
void* p = _aligned_malloc(size,16);
return (Foo*)p;
}
}
This would create a set of bytes 32 byte memory correct?