I came across following code here.
/* Allocate aligned memory in a portable way. * * Memory allocated with aligned alloc *MUST* be freed using aligned_free.