Skip to content

Commit ba20eea

Browse files
committed
Use constant to initialize struct in Rust > 1.25
1 parent 37a0753 commit ba20eea

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/symbolize/dbghelp.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,18 @@ impl Symbol {
7373
struct Aligned8<T>(T);
7474

7575
pub unsafe fn resolve(addr: *mut c_void, cb: &mut FnMut(&super::Symbol)) {
76-
let size: usize = 2 * MAX_SYM_NAME + mem::size_of::<SYMBOL_INFOW>();
7776
#[cfg(rustc_1_25)]
78-
let mut data = Aligned8([0u8; size]);
79-
#[cfg(not(rustc_1_25))]
80-
let mut data = vec![0u8; size];
81-
77+
const SIZE: usize = 2 * MAX_SYM_NAME + mem::size_of::<SYMBOL_INFOW>();
78+
#[cfg(rustc_1_25)]
79+
let mut data = Aligned8([0u8; SIZE]);
8280
#[cfg(rustc_1_25)]
8381
let data = &mut data.0;
8482

83+
#[cfg(not(rustc_1_25))]
84+
let size: usize = 2 * MAX_SYM_NAME + mem::size_of::<SYMBOL_INFOW>();
85+
#[cfg(not(rustc_1_25))]
86+
let mut data = vec![0u8; size];
87+
8588
let info = &mut *(data.as_mut_ptr() as *mut SYMBOL_INFOW);
8689
info.MaxNameLen = MAX_SYM_NAME as ULONG;
8790
// the struct size in C. the value is different to

0 commit comments

Comments
 (0)