Skip to content

Commit

Permalink
Merge pull request #5331 from wasmerio/fix/wasix-public-memory
Browse files Browse the repository at this point in the history
Make memory access functions in WasiEnv public
  • Loading branch information
Arshia001 authored Jan 10, 2025
2 parents b405c52 + 1bddec9 commit 8ea093a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/wasix/src/state/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,17 +911,19 @@ impl WasiEnv {

/// Providers safe access to the memory
/// (it must be initialized before it can be used)
///
/// # Safety
/// This has been marked as unsafe as it will panic if its executed
/// on the wrong thread or before the inner is set
pub(crate) unsafe fn memory(&self) -> WasiInstanceGuardMemory<'_> {
pub unsafe fn memory(&self) -> WasiInstanceGuardMemory<'_> {
self.try_memory().expect(
"You must initialize the WasiEnv before using it and can not pass it between threads",
)
}

/// Providers safe access to the memory
/// (it must be initialized before it can be used)
pub(crate) fn try_memory_view<'a>(
pub fn try_memory_view<'a>(
&self,
store: &'a (impl AsStoreRef + ?Sized),
) -> Option<MemoryView<'a>> {
Expand All @@ -930,12 +932,11 @@ impl WasiEnv {

/// Providers safe access to the memory
/// (it must be initialized before it can be used)
///
/// # Safety
/// This has been marked as unsafe as it will panic if its executed
/// on the wrong thread or before the inner is set
pub(crate) unsafe fn memory_view<'a>(
&self,
store: &'a (impl AsStoreRef + ?Sized),
) -> MemoryView<'a> {
pub unsafe fn memory_view<'a>(&self, store: &'a (impl AsStoreRef + ?Sized)) -> MemoryView<'a> {
self.try_memory_view(store).expect(
"You must initialize the WasiEnv before using it and can not pass it between threads",
)
Expand Down

0 comments on commit 8ea093a

Please sign in to comment.