message: Avoid allocating huge amounts of memory when Slice is broken
diff: @@ -25,25 +25,25 @@ unsafe impl ValueType for Slice {}
  pub fn read_memory(ctx: &Ctx, ptr: u32) -> Vec<u8> {
  let slice = to_slice(ctx, ptr);
  let memory = ctx.memory(0);
  - let len = slice.len as usize;
  - let mut result = vec![0u8; len];
  // TODO: there must be a faster way to copy memory
  match WasmPtr::<u8, Array>::new(slice.offset).deref(memory, 0, slice.len) {
  Some(cells) => {
  + let len = slice.len as usize;
  + let mut result = vec![0u8; len];
  for i in 0..len {
  // result[i] = unsafe { cells.get_unchecked(i).get() }
  // resolved to memcpy, but only if we really start copying huge arrays
  result[i] = cells[i].get();
  }
  + result
  }
  None => panic!(
  "Error dereferencing slice {:?} in wasm memory of size {}. This typically happens when the given pointer does not point to a Slice struct.",
  slice,
  memory.size().bytes().0
  ),
  - };
  - result
  + }
  }
  // write_memory returns how many bytes written on success
  