MCPcopy Index your code
hub / github.com/jvilk/BrowserFS / Pointer_stringify

Function Pointer_stringify

test/tests/emscripten/readdir_empty.js:645–675  ·  view source on GitHub ↗
(ptr, /* optional */ length)

Source from the content-addressed store, hash-verified

643Module["getMemory"] = getMemory;
644
645function Pointer_stringify(ptr, /* optional */ length) {
646 if (length === 0 || !ptr) return '';
647 // TODO: use TextDecoder
648 // Find the length, and check for UTF while doing so
649 var hasUtf = 0;
650 var t;
651 var i = 0;
652 while (1) {
653 t = HEAPU8[(((ptr)+(i))>>0)];
654 hasUtf |= t;
655 if (t == 0 && !length) break;
656 i++;
657 if (length && i == length) break;
658 }
659 if (!length) length = i;
660
661 var ret = '';
662
663 if (hasUtf < 128) {
664 var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
665 var curr;
666 while (length > 0) {
667 curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
668 ret = ret ? ret + curr : curr;
669 ptr += MAX_CHUNK;
670 length -= MAX_CHUNK;
671 }
672 return ret;
673 }
674 return Module['UTF8ToString'](ptr);
675}
676Module["Pointer_stringify"] = Pointer_stringify;
677
678// Given a pointer 'ptr' to a null-terminated ASCII-encoded string in the emscripten HEAP, returns

Callers 2

readdir_empty.jsFile · 0.70
demangleFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected