mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
e204d863a5
* Update Kubernetes to v1.22.1 * Update dependent modules to track with upstream Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
32 lines
642 B
Go
32 lines
642 B
Go
package internal
|
|
|
|
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])}
|
|
}
|
|
|
|
// 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)}
|
|
}
|