Remove some ffi wrappers

This commit is contained in:
Fabian Boehm
2025-01-24 16:24:08 +01:00
parent d69a9296a6
commit 545a23734e

15
src/env/mod.rs vendored
View File

@@ -26,17 +26,6 @@
static SETENV_LOCK: Mutex<()> = Mutex::new(());
mod ffi {
extern "C" {
pub fn setenv(
name: *const libc::c_char,
value: *const libc::c_char,
overwrite: libc::c_int,
);
pub fn unsetenv(name: *const libc::c_char);
}
}
/// Sets an environment variable after obtaining a lock, to try and improve the safety of
/// environment variables.
///
@@ -47,7 +36,7 @@ pub fn setenv_lock<S1: ToCString, S2: ToCString>(name: S1, value: S2, overwrite:
let value = value.to_cstring();
let _lock = SETENV_LOCK.lock();
unsafe {
self::ffi::setenv(name.as_ptr(), value.as_ptr(), libc::c_int::from(overwrite));
libc::setenv(name.as_ptr(), value.as_ptr(), libc::c_int::from(overwrite));
}
}
@@ -57,6 +46,6 @@ pub fn unsetenv_lock<S: ToCString>(name: S) {
let name = name.to_cstring();
let _lock = SETENV_LOCK.lock();
unsafe {
self::ffi::unsetenv(name.as_ptr());
libc::unsetenv(name.as_ptr());
}
}