diff options
Diffstat (limited to 'src/preamble.js')
-rw-r--r-- | src/preamble.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/preamble.js b/src/preamble.js index c6752c8f..8b10b3c2 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -132,7 +132,7 @@ function _putchar(p) { } function _strlen(p) { -// XXX hardcoded ptr impl + // XXX hardcoded ptr impl var q = p; while (HEAP[q] != 0) q++; return q - p; @@ -140,6 +140,11 @@ function _strlen(p) { // return p.slab.length; // XXX might want to find the null terminator... } +function String_copy(p) { + // XXX hardcoded ptr impl + return HEAP.slice(p, p+_strlen(p)).concat([0]); +} + // stdlib.h // Get a pointer, return int value of the string it points to |