I've been reading the legacy code,which invloves in the customized memory pooling system, then I found that the code uses _aligned_malloc. I wonder what is this function and when do I have to use it.
This function is useful when the alignment of your memory allocation is important to you. Alignment means that the numerical value of the pointer returned must be evenly divisible by a certain number, ie. ((unsigned int)ptr) % alignment should evaluate to 0.
An example of a reason for wanting a certain alignment is to use the data with the SSE instruction set on x86 where the data must be aligned to a multiple 16.
Thanks all of you.
I did read MSDN but what I wanted was the answer like "An example of a reason for wanting a certain alignment is to use the data with the SSE instruction set on x86 where the data must be aligned to a multiple 16".
I finally understood what those code means. thanks again.
Another example - ARM processor. It requires to align all data to 4 bytes.