Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
fix: safe initialization context of robot structs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tropix126 committed Mar 13, 2024
1 parent 5f36c18 commit 33c4959
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/pros-async/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ macro_rules! async_robot {

#[no_mangle]
extern "C" fn initialize() {
let robot = Default::default();
unsafe {
ROBOT = Some(Default::default());
ROBOT = Some(robot);
}
}
};
Expand All @@ -195,8 +196,9 @@ macro_rules! async_robot {

#[no_mangle]
extern "C" fn initialize() {
let robot = $init;
unsafe {
ROBOT = Some($init);
ROBOT = Some(robot);
}
}
};
Expand Down
6 changes: 4 additions & 2 deletions packages/pros-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ macro_rules! sync_robot {

#[no_mangle]
extern "C" fn initialize() {
let robot = Default::default();
unsafe {
ROBOT = Some(Default::default());
ROBOT = Some(robot);
}
}
};
Expand All @@ -133,8 +134,9 @@ macro_rules! sync_robot {

#[no_mangle]
extern "C" fn initialize() {
let robot = $init;
unsafe {
ROBOT = Some($init);
ROBOT = Some(robot);
}
}
};
Expand Down

0 comments on commit 33c4959

Please sign in to comment.