Refactor.

This commit is contained in:
Nuno Cruces
2023-01-28 12:47:39 +00:00
parent f4125bcd93
commit 0ace464670
7 changed files with 90 additions and 72 deletions

10
mem.go
View File

@@ -99,3 +99,13 @@ func (m memory) readString(ptr, maxlen uint32) string {
return string(buf[:i])
}
}
func (m memory) writeString(ptr uint32, s string) {
siz := uint32(len(s) + 1)
buf, ok := m.read(ptr, siz)
if !ok {
panic(rangeErr)
}
buf[len(s)] = 0
copy(buf, s)
}