mirror of
https://github.com/containers/podman.git
synced 2025-11-30 10:07:33 +08:00
fix(deps): update module github.com/shirou/gopsutil/v4 to v4.24.9
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
40
vendor/github.com/ebitengine/purego/internal/strings/strings.go
generated
vendored
Normal file
40
vendor/github.com/ebitengine/purego/internal/strings/strings.go
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||
|
||||
package strings
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// hasSuffix tests whether the string s ends with suffix.
|
||||
func hasSuffix(s, suffix string) bool {
|
||||
return len(s) >= len(suffix) && s[len(s)-len(suffix):] == suffix
|
||||
}
|
||||
|
||||
// CString converts a go string to *byte that can be passed to C code.
|
||||
func CString(name string) *byte {
|
||||
if hasSuffix(name, "\x00") {
|
||||
return &(*(*[]byte)(unsafe.Pointer(&name)))[0]
|
||||
}
|
||||
b := make([]byte, len(name)+1)
|
||||
copy(b, name)
|
||||
return &b[0]
|
||||
}
|
||||
|
||||
// GoString copies a null-terminated char* to a Go string.
|
||||
func GoString(c uintptr) string {
|
||||
// We take the address and then dereference it to trick go vet from creating a possible misuse of unsafe.Pointer
|
||||
ptr := *(*unsafe.Pointer)(unsafe.Pointer(&c))
|
||||
if ptr == nil {
|
||||
return ""
|
||||
}
|
||||
var length int
|
||||
for {
|
||||
if *(*byte)(unsafe.Add(ptr, uintptr(length))) == '\x00' {
|
||||
break
|
||||
}
|
||||
length++
|
||||
}
|
||||
return string(unsafe.Slice((*byte)(ptr), length))
|
||||
}
|
||||
Reference in New Issue
Block a user