MCPcopy Index your code
hub / github.com/google/gvisor / Flatten

Method Flatten

pkg/buffer/buffer.go:387–397  ·  view source on GitHub ↗

Flatten returns a flattened copy of this data. This method should not be used in any performance-sensitive paths. It may allocate a fresh byte slice sufficiently large to contain all the data in the buffer. This is principally for debugging. N.B. Tee data still belongs to this Buffer, as if there

()

Source from the content-addressed store, hash-verified

385// present, then it will be returned directly. This should be used for
386// temporary use only, and a reference to the given slice should not be held.
387func (b *Buffer) Flatten() []byte {
388 if v := b.data.Front(); v == nil {
389 return nil // No data at all.
390 }
391 data := make([]byte, 0, b.size) // Need to flatten.
392 for v := b.data.Front(); v != nil; v = v.Next() {
393 // Copy to the allocated slice.
394 data = append(data, v.AsSlice()...)
395 }
396 return data
397}
398
399// Size indicates the total amount of data available in this Buffer.
400func (b *Buffer) Size() int64 {

Callers 15

saveDataMethod · 0.95
TestBufferFunction · 0.95
TestSaveRestoreBufferFunction · 0.95
compareFragmentsFunction · 0.95
TestPacketFragmenterFunction · 0.95
compareFragmentsFunction · 0.95
TestReadFunction · 0.80
TestV4UnknownDestinationFunction · 0.80
TestV6UnknownDestinationFunction · 0.80

Calls 3

NextMethod · 0.65
FrontMethod · 0.45
AsSliceMethod · 0.45

Tested by 15

TestBufferFunction · 0.76
TestSaveRestoreBufferFunction · 0.76
compareFragmentsFunction · 0.76
TestPacketFragmenterFunction · 0.76
compareFragmentsFunction · 0.76
TestReadFunction · 0.64
TestV4UnknownDestinationFunction · 0.64
TestV6UnknownDestinationFunction · 0.64