Set errno in alloc functions and add further tests
Make malloc
, calloc
, realloc
, aligned_alloc
and memalign
set errno
upon failure (as specified by POSIX/glibc docs). Also add further tests to exercise all branches of these functions.
Note that this MR makes memalign
stricter in behavior, since it will now fail upon non-power-of-two alignment inputs (as described in glibc documentation) rather than just wrapping the underlying allocator function.