mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-22 21:21:33 +00:00
fill unsetenv for windows (#150)
* fill unsetenv * update usage of read_string_from_wasm * convert helper to return String * correct usage of helper fn, cargo fmt, and check in lock file change
This commit is contained in:
committed by
Lachlan Sneff
parent
663de770bf
commit
ce03e4464c
14
lib/emscripten/src/env/windows/mod.rs
vendored
14
lib/emscripten/src/env/windows/mod.rs
vendored
@ -70,14 +70,16 @@ pub fn _putenv(name: c_int, ctx: &mut Ctx) -> c_int {
|
||||
}
|
||||
|
||||
/// emscripten: _unsetenv // (name: *const char);
|
||||
pub fn _unsetenv(name: c_int, ctx: &mut Ctx) -> c_int {
|
||||
pub fn _unsetenv(name: u32, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::_unsetenv");
|
||||
|
||||
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name);
|
||||
|
||||
debug!("=> name({:?})", unsafe { CStr::from_ptr(name_addr) });
|
||||
|
||||
unsafe { unsetenv(name_addr) }
|
||||
let name = read_string_from_wasm(ctx.memory(0), name);
|
||||
// no unsetenv on windows, so use putenv with an empty value
|
||||
let unsetenv_string = format!("{}=", name);
|
||||
let unsetenv_cstring = CString::new(unsetenv_string).unwrap();
|
||||
let unsetenv_raw_ptr = unsetenv_cstring.as_ptr();
|
||||
debug!("=> name({:?})", name);
|
||||
unsafe { putenv(unsetenv_raw_ptr) }
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
|
Reference in New Issue
Block a user