diff options
-rw-r--r-- | src/postamble.js | 10 | ||||
-rw-r--r-- | src/preamble.js | 6 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/postamble.js b/src/postamble.js index 971568cd..576366fe 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -4,10 +4,7 @@ Module.callMain = function callMain(args) { args = args || []; - if (!calledInit) { - initRuntime(); - calledInit = true; - } + ensureInitRuntime(); var argc = args.length+1; function pad() { @@ -58,10 +55,7 @@ Module.callMain = function callMain(args) { function run(args) { args = args || Module['arguments']; - if (!calledInit) { - initRuntime(); - calledInit = true; - } + ensureInitRuntime(); if (runDependencies > 0) { Module.printErr('run() called, but dependencies remain, so not running'); diff --git a/src/preamble.js b/src/preamble.js index e7778b30..f85cf4f3 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -718,7 +718,11 @@ var __ATINIT__ = []; // functions called during startup var __ATMAIN__ = []; // functions called when main() is to be run var __ATEXIT__ = []; // functions called during shutdown -function initRuntime() { +var runtimeInitialized = false; + +function ensureInitRuntime() { + if (runtimeInitialized) return; + runtimeInitialized = true; callRuntimeCallbacks(__ATINIT__); } function preMain() { |