Fix a typo in portability/Memory.cpp
authorMichael Lee <mzlee@fb.com>
Mon, 14 Mar 2016 16:34:01 +0000 (09:34 -0700)
committerFacebook Github Bot 3 <facebook-github-bot-3-bot@fb.com>
Mon, 14 Mar 2016 16:35:27 +0000 (09:35 -0700)
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
folly/test/RangeTest.cpp

index 60ce0330ed533164c5e32352979808a2ffb1e252..f57086af47831e28aaa0f3aef96470e51c640be4 100644 (file)
 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); }
 
index 8cbdb04d7b4d87620ede819c51e48e0444e6c357..42a76ac5e2f9bd98d4c77a5511d673a756d56790 100644 (file)
@@ -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);