This fixes the memory leaks in the following functions which should not be
returning "owned" pointers:
* `wasm_extern_as_func`
* `wasm_func_as_extern`
* `wasm_extern_as_global`
* `wasm_global_as_extern`
* `wasm_extern_as_memory`
* `wasm_extern_as_table`
Additionally, this commit implements the `wasm_memory_as_extern` and
`wasm_table_as_extern` functions.
Fixes#394.