mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 14:18:20 +00:00
@@ -122,7 +122,9 @@ pub unsafe fn copy_cstr_into_wasm(ctx: &EmEnv, cstr: *const c_char) -> u32 {
|
||||
space_offset
|
||||
}
|
||||
|
||||
pub unsafe fn allocate_on_stack<'a, T: Copy>(ctx: &'a EmEnv, count: u32) -> (u32, &'a mut [T]) {
|
||||
/// # Safety
|
||||
/// This method is unsafe because it operates directly with the slice of memory represented by the address
|
||||
pub unsafe fn allocate_on_stack<T: Copy>(ctx: &EmEnv, count: u32) -> (u32, &mut [T]) {
|
||||
let offset = get_emscripten_data(ctx)
|
||||
.stack_alloc_ref()
|
||||
.unwrap()
|
||||
@@ -135,6 +137,8 @@ pub unsafe fn allocate_on_stack<'a, T: Copy>(ctx: &'a EmEnv, count: u32) -> (u32
|
||||
(offset, slice)
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
/// This method is unsafe because it uses `allocate_on_stack` which is unsafe
|
||||
pub unsafe fn allocate_cstr_on_stack<'a>(ctx: &'a EmEnv, s: &str) -> (u32, &'a [u8]) {
|
||||
let (offset, slice) = allocate_on_stack(ctx, (s.len() + 1) as u32);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user