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?
int *p2 = aligned_alloc(1024, 1024*sizeof *p2);
orint *p2 = aligned_alloc(10, 10*sizeof *p2);
? Of course maybe the size ofint
could be 2,560, but I doubt that. – Ferde