The footer offset (diff between malloc'd address and aligned address)
is (alignment-1) at most, and footer appears `size' bytes after the
aligned address, thus required size is (alignment-1 + size + sizeof(*f)).
The existing code seems to allocate extra unused `size' bytes.
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
assert(!(alignment & (alignment - 1)));
- ptr = malloc(size + alignment + size + sizeof(*f) - 1);
+ ptr = malloc(size + alignment + sizeof(*f) - 1);
if (ptr) {
ret = PTR_ALIGN(ptr, alignment - 1);
f = ret + size;