diff --git a/source/m3_env.c b/source/m3_env.c index da53263..e170242 100644 --- a/source/m3_env.c +++ b/source/m3_env.c @@ -647,11 +647,11 @@ _ (ReadLEB_u32 (& functionIndex, & bytes, end)); _catch: return result; } -M3Result InitStartFunc (IM3Module io_module) +M3Result m3_RunStart (IM3Module io_module) { M3Result result = m3Err_none; - if (io_module->startFunction >= 0) + if (io_module and io_module->startFunction >= 0) { IM3Function function = & io_module->functions [io_module->startFunction]; @@ -750,7 +750,7 @@ M3Result m3_FindFunction (IM3Function * o_function, IM3Runtime i_runtime, cons // Check if start function needs to be called if (function and function->module->startFunction) { - result = InitStartFunc (function->module); + result = m3_RunStart (function->module); if (result) return result; } diff --git a/source/wasm3.h b/source/wasm3.h index 155ffbc..57a81d4 100644 --- a/source/wasm3.h +++ b/source/wasm3.h @@ -190,6 +190,9 @@ d_m3ErrorConst (trapStackOverflow, "[trap] stack overflow") M3Result m3_LoadModule (IM3Runtime io_runtime, IM3Module io_module); // LoadModule transfers ownership of a module to the runtime. Do not free modules once successfully imported into the runtime + // Calling m3_RunStart is optional + M3Result m3_RunStart (IM3Module i_module); + typedef const void * (* M3RawCall) (IM3Runtime runtime, IM3ImportContext _ctx, uint64_t * _sp, void * _mem); M3Result m3_LinkRawFunction (IM3Module io_module,