MCPcopy Create free account
hub / github.com/XTLS/Go / sliceForAppend

Function sliceForAppend

conn.go:485–494  ·  view source on GitHub ↗

sliceForAppend extends the input slice by n bytes. head is the full extended slice, while tail is the appended part. If the original slice has sufficient capacity no allocation is performed.

(in []byte, n int)

Source from the content-addressed store, hash-verified

483// slice, while tail is the appended part. If the original slice has sufficient
484// capacity no allocation is performed.
485func sliceForAppend(in []byte, n int) (head, tail []byte) {
486 if total := len(in) + n; cap(in) >= total {
487 head = in[:total]
488 } else {
489 head = make([]byte, total)
490 copy(head, in)
491 }
492 tail = head[len(in):]
493 return
494}
495
496// encrypt encrypts payload, adding the appropriate nonce and/or MAC, and
497// appends it to record, which must already contain the record header.

Callers 2

encryptMethod · 0.85
writeRecordLockedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…