encodeDstBufMaxLen function

int encodeDstBufMaxLen(
  1. int srcLen, {
  2. bool withZero = false,
})

Determine maximum encoded byte length for source containing srcLen bytes.

If withZero is true, the length is increased by 1 to allow room for a 0x00 byte to be appended to the end

Implementation

int encodeDstBufMaxLen(int srcLen, {bool withZero = false}) {
  return srcLen + (srcLen + 253) ~/ 254 + (withZero ? 1 : 0);
}