From ec4432a3883d2becf0468f014e3d3ed05c2f48e8 Mon Sep 17 00:00:00 2001 From: Ryan Lester Date: Wed, 4 Oct 2017 20:26:00 -0400 Subject: [PATCH] allow setting total memory from JS (#608) --- dist-build/emscripten.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dist-build/emscripten.sh b/dist-build/emscripten.sh index a360ef29..41365cc5 100755 --- a/dist-build/emscripten.sh +++ b/dist-build/emscripten.sh @@ -74,9 +74,13 @@ if [ "$DIST" = yes ]; then emccLibsodium "${PREFIX}/lib/libsodium.wasm.tmp.js" -O3 -s WASM=1 cat > "${PREFIX}/lib/libsodium.js" <<- EOM + var root = this.global || this.self || this.window || this; if (typeof Module === 'undefined') { var Module = {}; } + if (root.sodium && !isNaN(root.sodium.totalMemory)) { + Module.TOTAL_MEMORY = root.sodium.totalMemory; + } var _Module = Module; Module.ready = new Promise(function (resolve, reject) { var Module = _Module;