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)
| 483 | // slice, while tail is the appended part. If the original slice has sufficient |
| 484 | // capacity no allocation is performed. |
| 485 | func 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. |
no outgoing calls
no test coverage detected
searching dependent graphs…