You are looking for _ aligned_malloc . Note that memory must be freed using _aligned_free , and this alignment is limited to powers of 2.
If you need more flexibility, itโs not difficult for you to implement your own solution, for which malloc alignment + bytes pieces of memory start with.
Eugene Talagrand
source share