mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Fix undefined behavior in energymon::init
This commit is contained in:
parent
d186ab6927
commit
3160e62b8a
1 changed files with 1 additions and 2 deletions
|
@ -29,7 +29,6 @@ mod energymon {
|
||||||
|
|
||||||
use self::energy_monitor::EnergyMonitor;
|
use self::energy_monitor::EnergyMonitor;
|
||||||
use self::energymon::EnergyMon;
|
use self::energymon::EnergyMon;
|
||||||
use std::mem;
|
|
||||||
use std::sync::{Once, ONCE_INIT};
|
use std::sync::{Once, ONCE_INIT};
|
||||||
|
|
||||||
static mut EM: Option<*mut EnergyMon> = None;
|
static mut EM: Option<*mut EnergyMon> = None;
|
||||||
|
@ -41,7 +40,7 @@ mod energymon {
|
||||||
if let Ok(em) = EnergyMon::new() {
|
if let Ok(em) = EnergyMon::new() {
|
||||||
println!("Started energy monitoring from: {}", em.source());
|
println!("Started energy monitoring from: {}", em.source());
|
||||||
unsafe {
|
unsafe {
|
||||||
EM = Some(mem::transmute(Box::new(em)));
|
EM = Some(Box::into_raw(Box::new(em)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue