Created
April 19, 2012 06:22
-
-
Save christoph-buente/2419092 to your computer and use it in GitHub Desktop.
don't use mremap (not supported on Darwin)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/include/osmium/storage/byid.hpp b/include/osmium/storage/byid.hpp | |
index 718d4a2..78119bb 100644 | |
--- a/include/osmium/storage/byid.hpp | |
+++ b/include/osmium/storage/byid.hpp | |
@@ -32,6 +32,12 @@ You should have received a copy of the Licenses along with Osmium. If not, see | |
#include <fcntl.h> | |
#include <boost/utility.hpp> | |
+// Darwin uses a different name. | |
+#ifndef MAP_ANONYMOUS | |
+#define MAP_ANONYMOUS MAP_ANON | |
+#endif | |
+ | |
+ | |
namespace Osmium { | |
/** | |
@@ -320,7 +326,9 @@ namespace Osmium { | |
} | |
} | |
- m_items = static_cast<TValue*>(mremap(m_items, sizeof(TValue) * m_size, sizeof(TValue) * new_size, MREMAP_MAYMOVE)); | |
+ // use unmap/map instead of remap because Darwin doesn't support remap. | |
+ munmap(m_items, sizeof(TValue) * m_size); | |
+ m_items = (TValue*) mmap(NULL, sizeof(TValue) * new_size, PROT_READ|PROT_WRITE, MAP_SHARED, m_fd, 0); | |
if (m_items == MAP_FAILED) { | |
throw std::bad_alloc(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment