def dump_uvarint_b_into(n, buffer, offset=0):
    """
    Serializes n as variable size integer to the provided buffer.
    Buffer has to ha
    :param n:
    :param buffer:
    :param offset:
    :return:
    """
    shifted = True
    while shifted:
        shifted = n >> 7
        buffer[offset] = n & 127 | (128 if shifted else 0)
        offset += 1
        n = shifted
    return buffer
