Browse Source

Merge pull request #5245 from TheTophatDemon/fix-odin-js-loadcstring

Fix odin.js loadCstring to use pointer address correctly.
gingerBill 3 months ago
parent
commit
d52aa3f2c2
1 changed files with 3 additions and 7 deletions
  1. 3 7
      core/sys/wasm/js/odin.js

+ 3 - 7
core/sys/wasm/js/odin.js

@@ -110,16 +110,12 @@ class WasmMemoryInterface {
 	}
 
 	loadCstring(ptr) {
-		return this.loadCstringDirect(this.loadPtr(ptr));
-	}
-
-	loadCstringDirect(start) {
-		if (start == 0) {
+		if (ptr == 0) {
 			return null;
 		}
 		let len = 0;
-		for (; this.mem.getUint8(start+len) != 0; len += 1) {}
-		return this.loadString(start, len);
+		for (; this.mem.getUint8(ptr+len) != 0; len += 1) {}
+		return this.loadString(ptr, len);
 	}
 
 	storeU8(addr, value)  { this.mem.setUint8  (addr, value); }