aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/preamble.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 02935f8f..eb522975 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -299,11 +299,10 @@ function ccallFunc(func, returnType, argTypes, args) {
function toC(value, type) {
if (type == 'string') {
if (value === null || value === undefined || value === 0) return 0; // null string
- if (!stack) stack = Runtime.stackSave();
- var ret = Runtime.stackAlloc(value.length+1);
- writeStringToMemory(value, ret);
- return ret;
- } else if (type == 'array') {
+ value = intArrayFromString(value);
+ type = 'array';
+ }
+ if (type == 'array') {
if (!stack) stack = Runtime.stackSave();
var ret = Runtime.stackAlloc(value.length);
writeArrayToMemory(value, ret);