I'm looking at the explanation of aligned-alloc(): http://en.cppreference.com/w/c/memory/aligned_alloc
void *aligned_alloc( size_t alignment, size_t size );
"Allocate size bytes of uninitialized storage whose alignment is specified by alignment. The size parameter must be an integral multiple of alignment."
However, the example code uses it like this:
int *p2 = aligned_alloc(1024, 10*sizeof *p2);
10*sizeof *p equals 40, so it's not an integral multiple of 1024.
What do I misunderstand?
Actually, it seems like C11 standard cannot make up its own mind, and keeps changing the requirements: initially it was an undefined behavior, then with DR 460 they changed it to fail and return null pointer, and now it seems like they want to change it to accept any values as arguments: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2072.htm
And compilers seem to not care about those restrictions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With