Index: runtime/bin/file_macos.cc |
diff --git a/runtime/bin/file_macos.cc b/runtime/bin/file_macos.cc |
index 842982f1dd98fa72909298613818b01c6f850037..f3d282941cd971f55fb28989387b52d757fadf6a 100644 |
--- a/runtime/bin/file_macos.cc |
+++ b/runtime/bin/file_macos.cc |
@@ -81,7 +81,7 @@ bool File::IsClosed() { |
} |
-void* File::Map(MapType type, int64_t position, int64_t length) { |
+MappedMemory* File::Map(MapType type, int64_t position, int64_t length) { |
ASSERT(handle_->fd() >= 0); |
int prot = PROT_NONE; |
switch (type) { |
@@ -98,7 +98,15 @@ void* File::Map(MapType type, int64_t position, int64_t length) { |
if (addr == MAP_FAILED) { |
return NULL; |
} |
- return addr; |
+ return new MappedMemory(addr, length); |
+} |
+ |
+ |
+void MappedMemory::Unmap() { |
+ int result = munmap(address_, size_); |
+ ASSERT(result == 0); |
+ address_ = 0; |
+ size_ = 0; |
} |