Skip to content

Commit

Permalink
Regression: move unsafe{} block to cover the full assignment. The uns…
Browse files Browse the repository at this point in the history
…afe part of this assignment is itself, not the right-hand side.
  • Loading branch information
Connor-GH committed Oct 16, 2024
1 parent 3ad3930 commit 1df2da2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hpx-examples/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![feature(vec_into_raw_parts)]
#![feature(random)]
use core::array::from_fn;
use std::{env, ffi::c_char, process, random};
use std::{env, process, random};

fn hpx_main(_: Vec<String>) -> i32 {
let numbers: &[i32; 16384] = &from_fn(|_| random::random::<i32>());
Expand Down
4 changes: 2 additions & 2 deletions hpx-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use std::env::Args;
use std::ffi::{CString, CStr};
use std::os::raw::c_char;

static FUNC_HOLDER: Option<fn (Vec<String>) -> i32> = None;
static mut FUNC_HOLDER: Option<fn (Vec<String>) -> i32> = None;

// Convert arguments from *mut *mut c_char to Vec<String>
// and call the saved Rust version of the function.
Expand All @@ -66,7 +66,7 @@ fn c_init(argc: i32, argv: *mut *mut c_char) -> i32 {

pub fn init(func: fn(Vec<String>) -> i32, func_args: Vec<String>) -> i32
{
FUNC_HOLDER = unsafe { Some(func) };
unsafe { FUNC_HOLDER = Some(func) };
let str_args: Vec<&str> = func_args
.iter()
.map(|s| s.as_str())
Expand Down

0 comments on commit 1df2da2

Please sign in to comment.