{"action":"created","comment":{"url":"https://api.github.com/repos/danburkert/mmap/pulls/comments/37142268","id":37142268,"diff_hunk":"@@ -0,0 +1,89 @@\n+use std::{ io, slice };\n+use std::rc::Rc;\n+use std::cell::RefCell;\n+\n+extern crate libc;\n+\n+use ::Mmap;\n+\n+#[cfg(target_os = \"windows\")]\n+use super::windows::MmapInner;\n+\n+#[cfg(not(target_os = \"windows\"))]\n+use super::posix::MmapInner;\n+\n+pub struct MmapSliver {\n+\t// The Rc tracks when to drop\n+\t// The RefCell allows mutable borrows of parent\n+\t// for flushing\n+\tparent: Rc< RefCell<Mmap> >,\n+\tinner: MmapInner\n+}\n+\n+pub unsafe fn carve(mmap: Mmap, ranges: Vec<(usize,usize)> ) -> Vec<MmapSliver> {\n+\tlet parent = Rc::new( RefCell::new(mmap) );\n+\n+\tlet ptr = parent.borrow().ptr() as *mut libc::c_void;\n+\n+    ranges.into_iter().map(|(start_offset,end_offset)| {\n+        MmapSliver {\n+            parent: parent.clone(),\n+            inner: MmapInner {\n+                ptr: ptr.offset(start_offset as isize),\n+                len: (end_offset-start_offset)\n+            }\n+        }\n+    }).collect()\n+}\n+\n+impl MmapSliver {\n+    pub fn flush(&mut self) -> io::Result<()> {","path":"src/mmap_sliver.rs","position":40,"original_position":40,"commit_id":"67beda566d25d3be65c55d3119637811eab4a385","original_commit_id":"67beda566d25d3be65c55d3119637811eab4a385","user":{"login":"danburkert","id":160242,"avatar_url":"https://avatars.githubusercontent.com/u/160242?v=3","gravatar_id":"","url":"https://api.github.com/users/danburkert","html_url":"https://github.com/danburkert","followers_url":"https://api.github.com/users/danburkert/followers","following_url":"https://api.github.com/users/danburkert/following{/other_user}","gists_url":"https://api.github.com/users/danburkert/gists{/gist_id}","starred_url":"https://api.github.com/users/danburkert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danburkert/subscriptions","organizations_url":"https://api.github.com/users/danburkert/orgs","repos_url":"https://api.github.com/users/danburkert/repos","events_url":"https://api.github.com/users/danburkert/events{/privacy}","received_events_url":"https://api.github.com/users/danburkert/received_events","type":"User","site_admin":false},"body":"This could eventually use `msync` to just flush the bytes in the sliver.","created_at":"2015-08-16T05:41:57Z","updated_at":"2015-08-16T05:41:57Z","html_url":"https://github.com/danburkert/mmap/pull/10#discussion_r37142268","pull_request_url":"https://api.github.com/repos/danburkert/mmap/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/danburkert/mmap/pulls/comments/37142268"},"html":{"href":"https://github.com/danburkert/mmap/pull/10#discussion_r37142268"},"pull_request":{"href":"https://api.github.com/repos/danburkert/mmap/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/danburkert/mmap/pulls/10","id":42431372,"html_url":"https://github.com/danburkert/mmap/pull/10","diff_url":"https://github.com/danburkert/mmap/pull/10.diff","patch_url":"https://github.com/danburkert/mmap/pull/10.patch","issue_url":"https://api.github.com/repos/danburkert/mmap/issues/10","number":10,"state":"open","locked":false,"title":"Carve","user":{"login":"xrl","id":693059,"avatar_url":"https://avatars.githubusercontent.com/u/693059?v=3","gravatar_id":"","url":"https://api.github.com/users/xrl","html_url":"https://github.com/xrl","followers_url":"https://api.github.com/users/xrl/followers","following_url":"https://api.github.com/users/xrl/following{/other_user}","gists_url":"https://api.github.com/users/xrl/gists{/gist_id}","starred_url":"https://api.github.com/users/xrl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xrl/subscriptions","organizations_url":"https://api.github.com/users/xrl/orgs","repos_url":"https://api.github.com/users/xrl/repos","events_url":"https://api.github.com/users/xrl/events{/privacy}","received_events_url":"https://api.github.com/users/xrl/received_events","type":"User","site_admin":false},"body":"I'm hacking away on the idea of \"carving\" a mmap in to many slivers. I'm thinking in the same vein as `split_at_mut`. The code consumes a Mmap and uses `Rc` to keep the `Mmap` alive long enough so slivers are always valid.\r\n\r\n - [ ] Doesn't work. Segfault up at the end of the `cargo test` run\r\n - [ ] Come up with good names for what's going on. The names `carve`/`sliver` aren't great\r\n - [ ] Revert changes to make `Mmap` properties `pub` (create a constructor function `with_raw_parts`?)\r\n - [ ] Does this need a multithreaded version as well?\r\n\r\nDoes this look at all sane? If I can get it to work it will really scratch my itch for safely carving up a Mmap and moving those slivers in to structs.","created_at":"2015-08-14T07:44:40Z","updated_at":"2015-08-16T05:41:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"99b3a69572b1790c3c8c6311967a5086958ac383","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/danburkert/mmap/pulls/10/commits","review_comments_url":"https://api.github.com/repos/danburkert/mmap/pulls/10/comments","review_comment_url":"https://api.github.com/repos/danburkert/mmap/pulls/comments{/number}","comments_url":"https://api.github.com/repos/danburkert/mmap/issues/10/comments","statuses_url":"https://api.github.com/repos/danburkert/mmap/statuses/67beda566d25d3be65c55d3119637811eab4a385","head":{"label":"tureus:carve","ref":"carve","sha":"67beda566d25d3be65c55d3119637811eab4a385","user":{"login":"tureus","id":8347289,"avatar_url":"https://avatars.githubusercontent.com/u/8347289?v=3","gravatar_id":"","url":"https://api.github.com/users/tureus","html_url":"https://github.com/tureus","followers_url":"https://api.github.com/users/tureus/followers","following_url":"https://api.github.com/users/tureus/following{/other_user}","gists_url":"https://api.github.com/users/tureus/gists{/gist_id}","starred_url":"https://api.github.com/users/tureus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tureus/subscriptions","organizations_url":"https://api.github.com/users/tureus/orgs","repos_url":"https://api.github.com/users/tureus/repos","events_url":"https://api.github.com/users/tureus/events{/privacy}","received_events_url":"https://api.github.com/users/tureus/received_events","type":"Organization","site_admin":false},"repo":{"id":40576778,"name":"mmap","full_name":"tureus/mmap","owner":{"login":"tureus","id":8347289,"avatar_url":"https://avatars.githubusercontent.com/u/8347289?v=3","gravatar_id":"","url":"https://api.github.com/users/tureus","html_url":"https://github.com/tureus","followers_url":"https://api.github.com/users/tureus/followers","following_url":"https://api.github.com/users/tureus/following{/other_user}","gists_url":"https://api.github.com/users/tureus/gists{/gist_id}","starred_url":"https://api.github.com/users/tureus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tureus/subscriptions","organizations_url":"https://api.github.com/users/tureus/orgs","repos_url":"https://api.github.com/users/tureus/repos","events_url":"https://api.github.com/users/tureus/events{/privacy}","received_events_url":"https://api.github.com/users/tureus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tureus/mmap","description":"cross-platform Rust API for memory-mapped IO","fork":true,"url":"https://api.github.com/repos/tureus/mmap","forks_url":"https://api.github.com/repos/tureus/mmap/forks","keys_url":"https://api.github.com/repos/tureus/mmap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tureus/mmap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tureus/mmap/teams","hooks_url":"https://api.github.com/repos/tureus/mmap/hooks","issue_events_url":"https://api.github.com/repos/tureus/mmap/issues/events{/number}","events_url":"https://api.github.com/repos/tureus/mmap/events","assignees_url":"https://api.github.com/repos/tureus/mmap/assignees{/user}","branches_url":"https://api.github.com/repos/tureus/mmap/branches{/branch}","tags_url":"https://api.github.com/repos/tureus/mmap/tags","blobs_url":"https://api.github.com/repos/tureus/mmap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tureus/mmap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tureus/mmap/git/refs{/sha}","trees_url":"https://api.github.com/repos/tureus/mmap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tureus/mmap/statuses/{sha}","languages_url":"https://api.github.com/repos/tureus/mmap/languages","stargazers_url":"https://api.github.com/repos/tureus/mmap/stargazers","contributors_url":"https://api.github.com/repos/tureus/mmap/contributors","subscribers_url":"https://api.github.com/repos/tureus/mmap/subscribers","subscription_url":"https://api.github.com/repos/tureus/mmap/subscription","commits_url":"https://api.github.com/repos/tureus/mmap/commits{/sha}","git_commits_url":"https://api.github.com/repos/tureus/mmap/git/commits{/sha}","comments_url":"https://api.github.com/repos/tureus/mmap/comments{/number}","issue_comment_url":"https://api.github.com/repos/tureus/mmap/issues/comments{/number}","contents_url":"https://api.github.com/repos/tureus/mmap/contents/{+path}","compare_url":"https://api.github.com/repos/tureus/mmap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tureus/mmap/merges","archive_url":"https://api.github.com/repos/tureus/mmap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tureus/mmap/downloads","issues_url":"https://api.github.com/repos/tureus/mmap/issues{/number}","pulls_url":"https://api.github.com/repos/tureus/mmap/pulls{/number}","milestones_url":"https://api.github.com/repos/tureus/mmap/milestones{/number}","notifications_url":"https://api.github.com/repos/tureus/mmap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tureus/mmap/labels{/name}","releases_url":"https://api.github.com/repos/tureus/mmap/releases{/id}","created_at":"2015-08-12T02:48:52Z","updated_at":"2015-08-12T02:48:52Z","pushed_at":"2015-08-14T07:40:06Z","git_url":"git://github.com/tureus/mmap.git","ssh_url":"git@github.com:tureus/mmap.git","clone_url":"https://github.com/tureus/mmap.git","svn_url":"https://github.com/tureus/mmap","homepage":"","size":1023,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"danburkert:master","ref":"master","sha":"10b7773fdfa77d914d68637bcaafd03131fbc1e3","user":{"login":"danburkert","id":160242,"avatar_url":"https://avatars.githubusercontent.com/u/160242?v=3","gravatar_id":"","url":"https://api.github.com/users/danburkert","html_url":"https://github.com/danburkert","followers_url":"https://api.github.com/users/danburkert/followers","following_url":"https://api.github.com/users/danburkert/following{/other_user}","gists_url":"https://api.github.com/users/danburkert/gists{/gist_id}","starred_url":"https://api.github.com/users/danburkert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danburkert/subscriptions","organizations_url":"https://api.github.com/users/danburkert/orgs","repos_url":"https://api.github.com/users/danburkert/repos","events_url":"https://api.github.com/users/danburkert/events{/privacy}","received_events_url":"https://api.github.com/users/danburkert/received_events","type":"User","site_admin":false},"repo":{"id":33422338,"name":"mmap","full_name":"danburkert/mmap","owner":{"login":"danburkert","id":160242,"avatar_url":"https://avatars.githubusercontent.com/u/160242?v=3","gravatar_id":"","url":"https://api.github.com/users/danburkert","html_url":"https://github.com/danburkert","followers_url":"https://api.github.com/users/danburkert/followers","following_url":"https://api.github.com/users/danburkert/following{/other_user}","gists_url":"https://api.github.com/users/danburkert/gists{/gist_id}","starred_url":"https://api.github.com/users/danburkert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danburkert/subscriptions","organizations_url":"https://api.github.com/users/danburkert/orgs","repos_url":"https://api.github.com/users/danburkert/repos","events_url":"https://api.github.com/users/danburkert/events{/privacy}","received_events_url":"https://api.github.com/users/danburkert/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danburkert/mmap","description":"cross-platform Rust API for memory-mapped IO","fork":false,"url":"https://api.github.com/repos/danburkert/mmap","forks_url":"https://api.github.com/repos/danburkert/mmap/forks","keys_url":"https://api.github.com/repos/danburkert/mmap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danburkert/mmap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danburkert/mmap/teams","hooks_url":"https://api.github.com/repos/danburkert/mmap/hooks","issue_events_url":"https://api.github.com/repos/danburkert/mmap/issues/events{/number}","events_url":"https://api.github.com/repos/danburkert/mmap/events","assignees_url":"https://api.github.com/repos/danburkert/mmap/assignees{/user}","branches_url":"https://api.github.com/repos/danburkert/mmap/branches{/branch}","tags_url":"https://api.github.com/repos/danburkert/mmap/tags","blobs_url":"https://api.github.com/repos/danburkert/mmap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danburkert/mmap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danburkert/mmap/git/refs{/sha}","trees_url":"https://api.github.com/repos/danburkert/mmap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danburkert/mmap/statuses/{sha}","languages_url":"https://api.github.com/repos/danburkert/mmap/languages","stargazers_url":"https://api.github.com/repos/danburkert/mmap/stargazers","contributors_url":"https://api.github.com/repos/danburkert/mmap/contributors","subscribers_url":"https://api.github.com/repos/danburkert/mmap/subscribers","subscription_url":"https://api.github.com/repos/danburkert/mmap/subscription","commits_url":"https://api.github.com/repos/danburkert/mmap/commits{/sha}","git_commits_url":"https://api.github.com/repos/danburkert/mmap/git/commits{/sha}","comments_url":"https://api.github.com/repos/danburkert/mmap/comments{/number}","issue_comment_url":"https://api.github.com/repos/danburkert/mmap/issues/comments{/number}","contents_url":"https://api.github.com/repos/danburkert/mmap/contents/{+path}","compare_url":"https://api.github.com/repos/danburkert/mmap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danburkert/mmap/merges","archive_url":"https://api.github.com/repos/danburkert/mmap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danburkert/mmap/downloads","issues_url":"https://api.github.com/repos/danburkert/mmap/issues{/number}","pulls_url":"https://api.github.com/repos/danburkert/mmap/pulls{/number}","milestones_url":"https://api.github.com/repos/danburkert/mmap/milestones{/number}","notifications_url":"https://api.github.com/repos/danburkert/mmap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danburkert/mmap/labels{/name}","releases_url":"https://api.github.com/repos/danburkert/mmap/releases{/id}","created_at":"2015-04-04T22:20:58Z","updated_at":"2015-08-15T14:50:35Z","pushed_at":"2015-08-16T05:33:58Z","git_url":"git://github.com/danburkert/mmap.git","ssh_url":"git@github.com:danburkert/mmap.git","clone_url":"https://github.com/danburkert/mmap.git","svn_url":"https://github.com/danburkert/mmap","homepage":"","size":1522,"stargazers_count":5,"watchers_count":5,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":11,"mirror_url":null,"open_issues_count":7,"forks":11,"open_issues":7,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/danburkert/mmap/pulls/10"},"html":{"href":"https://github.com/danburkert/mmap/pull/10"},"issue":{"href":"https://api.github.com/repos/danburkert/mmap/issues/10"},"comments":{"href":"https://api.github.com/repos/danburkert/mmap/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/danburkert/mmap/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/danburkert/mmap/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/danburkert/mmap/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/danburkert/mmap/statuses/67beda566d25d3be65c55d3119637811eab4a385"}}}}