Commit 1fc548e1 authored by Jim Meyering's avatar Jim Meyering Committed by Sara Golemon

folly/test: correct an erroneous test for failed mmap

Summary:
* folly/test/AtomicHashArrayTest.cpp (MmapAllocator):
Upon failure, mmap returns MAP_FAILED, not NULL.

Test Plan:
fbconfig -r folly/test:atomic_hash_array_test && fbmake runtests

Reviewed By: mwang@fb.com

FB internal diff: D1481080

Tasks: 4846893
parent 942204a4
...@@ -81,7 +81,7 @@ class MmapAllocator { ...@@ -81,7 +81,7 @@ class MmapAllocator {
T *allocate(size_t n) { T *allocate(size_t n) {
void *p = mmap(nullptr, n * sizeof(T), PROT_READ | PROT_WRITE, void *p = mmap(nullptr, n * sizeof(T), PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANONYMOUS, -1, 0); MAP_SHARED | MAP_ANONYMOUS, -1, 0);
if (!p) throw std::bad_alloc(); if (p == MAP_FAILED) throw std::bad_alloc();
return (T *)p; return (T *)p;
} }
......
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