Skip to content

Commit

Permalink
sysenc: export buffer.Bytes()
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Beckers <timo@isovalent.com>
  • Loading branch information
ti-mo committed Oct 2, 2024
1 parent 856ae1f commit 4290021
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/sysenc/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ func SyscallOutput(dst any, size int) Buffer {
//
// Returns the number of copied bytes.
func (b Buffer) CopyTo(dst []byte) int {
return copy(dst, b.unsafeBytes())
return copy(dst, b.Bytes())
}

// AppendTo appends the buffer onto dst.
func (b Buffer) AppendTo(dst []byte) []byte {
return append(dst, b.unsafeBytes()...)
return append(dst, b.Bytes()...)
}

// Pointer returns the location where a syscall should write.
Expand All @@ -72,10 +72,12 @@ func (b Buffer) Unmarshal(data any) error {
return nil
}

return Unmarshal(data, b.unsafeBytes())
return Unmarshal(data, b.Bytes())
}

func (b Buffer) unsafeBytes() []byte {
// Bytes returns the buffer as a byte slice. Returns nil if the Buffer was
// created using UnsafeBuffer or by zero-copy unmarshaling.
func (b Buffer) Bytes() []byte {
if b.size == syscallPointerOnly {
return nil
}
Expand Down

0 comments on commit 4290021

Please sign in to comment.