mem: fix mem.Clear

This commit is contained in:
Judah Caruso 2026-02-13 11:34:22 -06:00
parent 04a5d3969d
commit 5a76937255

View file

@ -73,9 +73,9 @@ func Copy(dst, src unsafe.Pointer, size uintptr) unsafe.Pointer {
// Returns dst. // Returns dst.
func Clear(dst unsafe.Pointer, value byte, count uintptr) unsafe.Pointer { func Clear(dst unsafe.Pointer, value byte, count uintptr) unsafe.Pointer {
b := (*byte)(dst) b := (*byte)(dst)
for range count { // @todo: loop unroll/maybe use asm? for range count {
*b = value *b = value
b = (*byte)(unsafe.Add(dst, 1)) b = (*byte)(unsafe.Add(unsafe.Pointer(b), 1))
} }
return dst return dst
} }