Skip to content

Commit

Permalink
use sodiumoxide for mlock
Browse files Browse the repository at this point in the history
  • Loading branch information
radu committed Jun 23, 2024
1 parent ba3fab1 commit 4660b40
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ fn zeroize1(arr: &Bound<'_, PyAny>, py: Python<'_>) -> PyResult<()> {
#[pyfunction]
fn mlock(arr: &Bound<'_, PyAny>, py: Python<'_>) -> PyResult<()> {
let arr = as_array_mut(arr, py)?;
// if !_mlock(arr.as_mut_ptr(), arr.len()) {
sodiumoxide::utils::mlock(arr).map_err(|_|PyErr::new::<pyo3::exceptions::PyTypeError, _>(
"mlock failed",
))?;
unsafe {
if !_mlock(arr.as_mut_ptr(), arr.len()) {
return Err(PyErr::new::<pyo3::exceptions::PyTypeError, _>(
"mlock failed",
));
}
}
// sodiumoxide::utils::mlock(arr).map_err(|_|PyErr::new::<pyo3::exceptions::PyTypeError, _>(
// "mlock failed",
// ))?;
Ok(())
}

Expand Down

0 comments on commit 4660b40

Please sign in to comment.