mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 10:25:37 +00:00
internal/unsafe: fix empty slice
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
@@ -35,12 +35,10 @@ func SliceOf(s uintptr) []byte {
|
|||||||
// GoString convert a NUL-terminated C string
|
// GoString convert a NUL-terminated C string
|
||||||
// to a Go string.
|
// to a Go string.
|
||||||
func GoString(s []byte) string {
|
func GoString(s []byte) string {
|
||||||
i := 0
|
for i, v := range s {
|
||||||
for {
|
if v == 0 {
|
||||||
if s[i] == 0 {
|
return string(s[:i])
|
||||||
break
|
|
||||||
}
|
}
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
return string(s[:i])
|
return string(s)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user