MCPcopy Create free account
hub / github.com/apache/tvm / loadCString

Method loadCString

web/src/memory.ts:144–159  ·  view source on GitHub ↗

* Load null-terminated C-string from ptr. * @param ptr The head address

(ptr: Pointer)

Source from the content-addressed store, hash-verified

142 * @param ptr The head address
143 */
144 loadCString(ptr: Pointer): string {
145 if (this.buffer != this.memory.buffer) {
146 this.updateViews();
147 }
148 // NOTE: the views are still valid for read.
149 const ret = [];
150 let ch = 1;
151 while (ch != 0) {
152 ch = this.viewU8[ptr];
153 if (ch != 0) {
154 ret.push(String.fromCharCode(ch));
155 }
156 ++ptr;
157 }
158 return ret.join("");
159 }
160 /**
161 * Store raw bytes to the ptr.
162 * @param ptr The head address.

Callers 1

checkCallMethod · 0.80

Calls 2

updateViewsMethod · 0.95
joinMethod · 0.45

Tested by

no test coverage detected