Add wasm-c-api nested function calls sample (#652)

And enable to copy back the return value of wasm main function when calling wasm_application_execute_main, add license headers in wasm-c-api samples, fix several issues reported by klocwork.
This commit is contained in:
Wenyong Huang
2021-06-16 15:26:28 +08:00
committed by GitHub
parent 1a4aa5ac2f
commit 77c71e559a
15 changed files with 357 additions and 9 deletions

View File

@ -182,6 +182,10 @@ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst,
ret = wasm_runtime_create_exec_env_and_call_wasm(module_inst, func,
argc1, argv1);
if (ret && func_type->result_count > 0 && argc > 0 && argv)
/* copy the return value */
*(int*)argv = (int)argv1[0];
if (argv_buf_offset)
wasm_runtime_module_free(module_inst, argv_buf_offset);
return ret;
@ -669,4 +673,4 @@ fail:
bh_assert(exception);
os_printf("%s\n", exception);
return false;
}
}