public void setBytes(
      final long memOffset, final long offset, final long length, final Bytes bytes) {

    if (offset >= bytes.size()) {
      clearBytes(memOffset, length);
      return;
    }

    final Bytes toCopy =
        bytes.slice((int) offset, Math.min((int) length, bytes.size() - (int) offset));
    setBytes(memOffset, length, toCopy);
  }
Copy the bytes from the provided number of bytes from the provided value to memory from the
provided offset.

<p>Note that this method will extend memory to accommodate the location assigned and bytes
copied and so never fails.

@param memOffset the location in memory at which to start copying the bytes of {@code value}.
@param offset the location in the source to start copying.
@param length the number of bytes to set in memory. Note that this value may differ from {@code
    value.size()}: if {@code numBytes < value.size()} bytes, only {@code numBytes} will be
    copied from {@code value}; if {@code numBytes < value.size()}, then only the bytes in
    {@code value} will be copied, but the memory will be expanded if necessary to cover {@code
    numBytes} (in other words, {@link #getActiveWords()} will return a value consistent with
    having set {@code numBytes} bytes, even if less than that have been concretely set due to
    {@code value} being smaller).
@param bytes the bytes to copy to memory from {@code location}.
evm/src/main/java/org/hyperledger/besu/evm/frame/Memory.java