The parameters for this function must be aligned on a 32-bit boundary; otherwise, the function will behave unpredictably on multiprocessor x86 systems and any non-x86 systems. See _aligned_malloc.
I see that currently all of the volatile variables are allocated on the stack. Does the compiler take care of the alignment? Does it treat volatile variables differently? Would one need to take special care if those variables were allocated on the heap?