Skip to content

Commit

Permalink
fix build on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
irvingoujAtDevolution committed Sep 20, 2024
1 parent 9413a6b commit 02c0b1f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions cryptovec/src/platform/unix.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
use crate::CryptoVec;
use libc::{c_void, mlock, munlock};
use std::alloc;
use libc::c_void;

/// Unlock memory on drop for Unix-based systems.
pub fn munlock(ptr: *const u8, len: usize) {
unsafe {
if munlock(ptr as *const c_void, len) != 0 {
panic!("Failed to unlock memory.");
if libc::munlock(ptr as *const c_void, len) != 0 {
panic!("Failed to unlock memory");
}
}
}

pub fn mlock(ptr: *const u8, len: usize) {
unsafe {
if mlock(ptr as *const c_void, len) != 0 {
panic!("Failed to lock memory.");
if libc::mlock(ptr as *const c_void, len) != 0 {
panic!("Failed to lock memory");
}
}
}
Expand Down

0 comments on commit 02c0b1f

Please sign in to comment.