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)
| 472 | // slice, while tail is the appended part. If the original slice has sufficient |
| 473 | // capacity no allocation is performed. |
| 474 | func sliceForAppend(in []byte, n int) (head, tail []byte) { |
| 475 | if total := len(in) + n; cap(in) >= total { |
| 476 | head = in[:total] |
| 477 | } else { |
| 478 | head = make([]byte, total) |
| 479 | copy(head, in) |
| 480 | } |
| 481 | tail = head[len(in):] |
| 482 | return |
| 483 | } |
| 484 | |
| 485 | // encrypt encrypts payload, adding the appropriate nonce and/or MAC, and |
| 486 | // appends it to record, which must already contain the record header. |
no outgoing calls
no test coverage detected
searching dependent graphs…