* Load null-terminated C-string from ptr. * @param ptr The head address
(ptr: Pointer)
| 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. |
no test coverage detected