Skip to content

Commit 70dc2d6

Browse files
committed
fix #89
1 parent 1f3b6a1 commit 70dc2d6

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

src/windows.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ fn new_map(unique_id: &str, map_size: usize, create: bool) -> Result<MapData, Sh
216216
(FILE_MAP_READ | FILE_MAP_WRITE).0,
217217
);
218218
let map_ptr = match MapViewOfFile(map_h.as_handle(), FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0) {
219-
Ok(v) => v as _,
219+
Ok(v) => v,
220220
Err(e) => {
221221
return Err(if create {
222222
ShmemError::MapCreateFailed(e.win32_error().unwrap().0)
@@ -227,25 +227,23 @@ fn new_map(unique_id: &str, map_size: usize, create: bool) -> Result<MapData, Sh
227227
};
228228
trace!("\t{:p}", map_ptr);
229229

230-
let mut new_map = MapData {
231-
owner: create,
232-
file_map: map_h,
233-
persistent_file,
234-
unique_id: unique_id.to_string(),
235-
map_size: 0,
236-
view: map_ptr,
237-
};
238-
239230
if !create {
240231
//Get the real size of the openned mapping
241232
let mut info = MEMORY_BASIC_INFORMATION::default();
242-
if let Err(e) = VirtualQuery(new_map.view.as_mut_ptr() as _, &mut info) {
233+
if let Err(e) = VirtualQuery(map_ptr.as_mut_ptr(), &mut info) {
243234
return Err(ShmemError::UnknownOsError(e.win32_error().unwrap().0));
244235
}
245-
new_map.map_size = info.RegionSize;
236+
map_size = info.RegionSize;
246237
}
247238

248-
Ok(new_map)
239+
Ok(MapData {
240+
owner: create,
241+
file_map: map_h,
242+
persistent_file,
243+
unique_id: unique_id.to_string(),
244+
map_size,
245+
view: map_ptr,
246+
})
249247
}
250248

251249
//Creates a mapping specified by the uid and size

0 commit comments

Comments
 (0)