From bddb362eb895c6c7b429362219d316b5f05c828d Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Mon, 14 Mar 2016 09:34:01 -0700 Subject: [PATCH] Fix a typo in portability/Memory.cpp Summary: Also, add error checking back in, and remove the empty WIN32 implementation. Reviewed By: francis-ma Differential Revision: D3047494 fb-gh-sync-id: 5a2a18cd1ca675a081ad2a9252c765ab56527b6b shipit-source-id: 5a2a18cd1ca675a081ad2a9252c765ab56527b6b --- folly/portability/Memory.cpp | 10 ++++------ folly/test/RangeTest.cpp | 3 +++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/folly/portability/Memory.cpp b/folly/portability/Memory.cpp index 60ce0330..f57086af 100644 --- a/folly/portability/Memory.cpp +++ b/folly/portability/Memory.cpp @@ -26,13 +26,11 @@ namespace folly { namespace detail { -#ifdef _WIN32 -void* aligned_malloc(size_t size, size_t align) { return nullptr; } +#if defined(__ANDROID__) && (__ANDROID_API__ <= 15) -void aligned_free(void* aligned_ptr) {} -#elif defined(__ANDROID__) && (__ANDROID_API__ <= 15) - -void* aligned_malloc(size_t size, size_t align) { return memalign(align, size) } +void* aligned_malloc(size_t size, size_t align) { + return memalign(align, size); +} void aligned_free(void* aligned_ptr) { free(aligned_ptr); } diff --git a/folly/test/RangeTest.cpp b/folly/test/RangeTest.cpp index 8cbdb04d..42a76ac5 100644 --- a/folly/test/RangeTest.cpp +++ b/folly/test/RangeTest.cpp @@ -979,6 +979,9 @@ void createProtectedBuf(StringPiece& contents, char** buf) { ASSERT_LE(contents.size(), kPageSize); const size_t kSuccess = 0; char* pageAlignedBuf = (char*)aligned_malloc(2 * kPageSize, kPageSize); + if (pageAlignedBuf == nullptr) { + ASSERT_FALSE(true); + } // Protect the page after the first full page-aligned region of the // malloc'ed buffer mprotect(pageAlignedBuf + kPageSize, kPageSize, PROT_NONE); -- 2.34.1