aboutsummaryrefslogtreecommitdiff
path: root/src/postamble.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-10-22 16:26:30 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-10-22 16:26:30 -0700
commit97f9f26f4bebc8db98608df6e7bcf45322ee189b (patch)
tree2ff62b9b5e3e4c4d97a97caa17ba5ccc77eec294 /src/postamble.js
parentc11c08094b855e8d6d00d84cbea0f4bf2b18ff72 (diff)
handle no-data worker api calls, and more tests
Diffstat (limited to 'src/postamble.js')
-rw-r--r--src/postamble.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/postamble.js b/src/postamble.js
index 365f77d0..a4c43018 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -122,18 +122,24 @@ onmessage = function(msg) {
var func = Module['_' + msg.data['funcName']];
if (!func) throw 'invalid worker function to call: ' + msg.data['funcName'];
var data = msg.data['data'];
- if (!data.byteLength) data = new Uint8Array(data);
- if (!buffer || bufferSize < data.length) {
- if (buffer) _free(buffer);
- bufferSize = data.length;
- buffer = _malloc(data.length);
+ if (data) {
+ if (!data.byteLength) data = new Uint8Array(data);
+ if (!buffer || bufferSize < data.length) {
+ if (buffer) _free(buffer);
+ bufferSize = data.length;
+ buffer = _malloc(data.length);
+ }
+ HEAPU8.set(data, buffer);
}
- HEAPU8.set(data, buffer);
inWorkerCall = true;
workerResponded = false;
workerCallbackId = msg.data['callbackId'];
- func(buffer, data.length);
+ if (data) {
+ func(buffer, data.length);
+ } else {
+ func(0, 0);
+ }
inWorkerCall = false;
}