summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-07-12 06:46:42 +0000
committerbors <bors@rust-lang.org>2014-07-12 06:46:42 +0000
commita5688ad22df15f74d5b4ad8231a9cfa6cd92296d (patch)
treee26226f485bd756ad682755ac95b6932bb86f002 /src/libstd
parent8a2b7a5c19d4ae83c883065b4ee53b450d45afce (diff)
parentfb02d54b97e1710c4d6eeca6556b604188891271 (diff)
downloadrust-a5688ad22df15f74d5b4ad8231a9cfa6cd92296d.tar.gz
rust-a5688ad22df15f74d5b4ad8231a9cfa6cd92296d.zip
auto merge of #15588 : alexcrichton/rust/issue-15478, r=cmr
If modified, you can safely unmap arbitrary memory. These fields are not
intended to be modified, so read-only accessors are the only ones that are
provided.

Closes #15478
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/os.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index db56b387f8d..1a5be089252 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -1277,12 +1277,9 @@ pub fn page_size() -> uint {
 /// The memory map is released (unmapped) when the destructor is run, so don't
 /// let it leave scope by accident if you want it to stick around.
 pub struct MemoryMap {
-    /// Pointer to the memory created or modified by this map.
-    pub data: *mut u8,
-    /// Number of bytes this map applies to
-    pub len: uint,
-    /// Type of mapping
-    pub kind: MemoryMapKind,
+    data: *mut u8,
+    len: uint,
+    kind: MemoryMapKind,
 }
 
 /// Type of memory map
@@ -1617,6 +1614,15 @@ impl Drop for MemoryMap {
     }
 }
 
+impl MemoryMap {
+    /// Returns the pointer to the memory created or modified by this map.
+    pub fn data(&self) -> *mut u8 { self.data }
+    /// Returns the number of bytes this map applies to.
+    pub fn len(&self) -> uint { self.len }
+    /// Returns the type of mapping this represents.
+    pub fn kind(&self) -> MemoryMapKind { self.kind }
+}
+
 #[cfg(target_os = "linux")]
 pub mod consts {
     pub use os::arch_consts::ARCH;