Commit bddb362e authored by Michael Lee's avatar Michael Lee Committed by Facebook Github Bot 3

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
parent 13c58db9
......@@ -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); }
......
......@@ -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);
......
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