![dependabot[bot]](/assets/img/avatar_default.png)
Bumps [github.com/containerd/cgroups/v3](https://github.com/containerd/cgroups) from 3.0.2 to 3.0.3. - [Release notes](https://github.com/containerd/cgroups/releases) - [Commits](https://github.com/containerd/cgroups/compare/v3.0.2...v3.0.3) --- updated-dependencies: - dependency-name: github.com/containerd/cgroups/v3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package sys
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
"github.com/cilium/ebpf/internal/unix"
|
|
)
|
|
|
|
// NewPointer creates a 64-bit pointer from an unsafe Pointer.
|
|
func NewPointer(ptr unsafe.Pointer) Pointer {
|
|
return Pointer{ptr: ptr}
|
|
}
|
|
|
|
// NewSlicePointer creates a 64-bit pointer from a byte slice.
|
|
func NewSlicePointer(buf []byte) Pointer {
|
|
if len(buf) == 0 {
|
|
return Pointer{}
|
|
}
|
|
|
|
return Pointer{ptr: unsafe.Pointer(&buf[0])}
|
|
}
|
|
|
|
// NewSlicePointerLen creates a 64-bit pointer from a byte slice.
|
|
//
|
|
// Useful to assign both the pointer and the length in one go.
|
|
func NewSlicePointerLen(buf []byte) (Pointer, uint32) {
|
|
return NewSlicePointer(buf), uint32(len(buf))
|
|
}
|
|
|
|
// NewStringPointer creates a 64-bit pointer from a string.
|
|
func NewStringPointer(str string) Pointer {
|
|
p, err := unix.BytePtrFromString(str)
|
|
if err != nil {
|
|
return Pointer{}
|
|
}
|
|
|
|
return Pointer{ptr: unsafe.Pointer(p)}
|
|
}
|
|
|
|
// NewStringSlicePointer allocates an array of Pointers to each string in the
|
|
// given slice of strings and returns a 64-bit pointer to the start of the
|
|
// resulting array.
|
|
//
|
|
// Use this function to pass arrays of strings as syscall arguments.
|
|
func NewStringSlicePointer(strings []string) Pointer {
|
|
sp := make([]Pointer, 0, len(strings))
|
|
for _, s := range strings {
|
|
sp = append(sp, NewStringPointer(s))
|
|
}
|
|
|
|
return Pointer{ptr: unsafe.Pointer(&sp[0])}
|
|
}
|