MCPcopy
hub / github.com/cilium/ebpf / LookupBytes

Method LookupBytes

map.go:893–903  ·  view source on GitHub ↗

LookupBytes gets a value from Map. Returns a nil value if a key doesn't exist.

(key any)

Source from the content-addressed store, hash-verified

891//
892// Returns a nil value if a key doesn't exist.
893func (m *Map) LookupBytes(key any) ([]byte, error) {
894 valueBytes := make([]byte, m.fullValueSize)
895 valuePtr := sys.UnsafeSlicePointer(valueBytes)
896
897 err := m.lookup(key, valuePtr, 0)
898 if errors.Is(err, ErrKeyNotExist) {
899 return nil, nil
900 }
901
902 return valueBytes, err
903}
904
905func (m *Map) lookupPerCPU(key, valueOut any, flags MapLookupFlags) error {
906 slice, err := ensurePerCPUSlice(valueOut)

Callers 2

TestMapCloseFunction · 0.45
TestNotExistFunction · 0.45

Calls 3

lookupMethod · 0.95
UnsafeSlicePointerFunction · 0.92
IsMethod · 0.45

Tested by 2

TestMapCloseFunction · 0.36
TestNotExistFunction · 0.36