message: Restore C api wasi from master
  Wasi changes are reserved for the full merge.
diff: @@ -328,6 +328,14 @@ pub unsafe extern "C" fn wasi_env_new(
  #[no_mangle]
  pub extern "C" fn wasi_env_delete(_state: Option<Box<wasi_env_t>>) {}
  +/// Set the memory on a [`wasi_env_t`].
  +#[no_mangle]
  +pub unsafe extern "C" fn wasi_env_set_memory(env: &mut wasi_env_t, memory: &wasm_memory_t) {
  + let mut store_mut = env.store.store_mut();
  + let wasi_env = env.inner.data_mut(&mut store_mut);
  + wasi_env.set_memory(memory.extern_.memory());
  +}
  +
  #[no_mangle]
  pub unsafe extern "C" fn wasi_env_read_stdout(
  env: &mut wasi_env_t,
  @@ -335,8 +343,8 @@ pub unsafe extern "C" fn wasi_env_read_stdout(
  buffer_len: usize,
  ) -> isize {
  let inner_buffer = slice::from_raw_parts_mut(buffer as *mut _, buffer_len as usize);
  - let store = env.store.store();
  - let state = env.inner.data(&store).state();
  + let mut store_mut = env.store.store_mut();
  + let state = env.inner.data_mut(&mut store_mut).state();
  if let Ok(mut stdout) = state.stdout() {
  if let Some(stdout) = stdout.as_mut() {
  @@ -515,10 +523,11 @@ pub unsafe extern "C" fn wasi_env_initialize_instance(
  store: &mut wasm_store_t,
  instance: &mut wasm_instance_t,
  ) -> bool {
  + let mem = c_try!(instance.inner.exports.get_memory("memory"); otherwise false);
  wasi_env
  .inner
  - .initialize(&mut store.inner.store_mut(), &instance.inner)
  - .unwrap();
  + .data_mut(&mut store.inner.store_mut())
  + .set_memory(mem.clone());
  true
  }
  