diff options
author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-01-22 17:58:16 -0500 |
---|---|---|
committer | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-01-22 17:58:16 -0500 |
commit | 8ff943af1652f2a0a57977e277dc8e56013a9e7c (patch) | |
tree | 0a78ccc6a4c0aff5db991ccaed8653f39f8f510d /src | |
parent | e434672ab004a527e7b179d43dc5aafc4e085809 (diff) |
Add support for non-null terminated strings to Pointer_stringify
Diffstat (limited to 'src')
-rw-r--r-- | src/preamble.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/preamble.js b/src/preamble.js index 5c5c21ea..103b786d 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -496,16 +496,18 @@ function allocate(slab, types, allocator) { } Module['allocate'] = allocate; -function Pointer_stringify(ptr) { +function Pointer_stringify(ptr, /* optional */ length) { + var nullTerminated = typeof(length) == "undefined"; var ret = ""; var i = 0; var t; var nullByte = String.fromCharCode(0); while (1) { t = String.fromCharCode({{{ makeGetValue('ptr', 'i', 'i8', 0, 1) }}}); - if (t == nullByte) { break; } else {} + if (nullTerminated && t == nullByte) { break; } else {} ret += t; i += 1; + if (!nullTerminated && i == length) { break; } } return ret; } |