Commit 95a3cedc authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

base/memory: better reporting of aligned memory allocation errors.

posix_memalign() returns an error value when it fails, but that value
is not forwarded to the user despite being valuable to understand what
the underlying problem of a failed allocation is. Make sure to display
the error code.

Chrome OS.

Bug: 918509
Test: Checked that software video decoding was still working on
Change-Id: I508d6cc6332a1a5c29e8f3cece56272969e99dcc
Reviewed-on: https://chromium-review.googlesource.com/c/1424108
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625100}
parent 7a172974
......@@ -28,8 +28,10 @@ void* AlignedAlloc(size_t size, size_t alignment) {
#elif defined(OS_ANDROID)
ptr = memalign(alignment, size);
#else
if (posix_memalign(&ptr, alignment, size))
if (int ret = posix_memalign(&ptr, alignment, size)) {
DLOG(ERROR) << "posix_memalign() returned with error " << ret;
ptr = nullptr;
}
#endif
// Since aligned allocations may fail for non-memory related reasons, force a
// crash if we encounter a failed allocation; maintaining consistent behavior
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment