Skip to content

Instantly share code, notes, and snippets.

@christoph-buente
Created April 19, 2012 06:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christoph-buente/2419092 to your computer and use it in GitHub Desktop.
Save christoph-buente/2419092 to your computer and use it in GitHub Desktop.
don't use mremap (not supported on Darwin)
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