def encodeInto(x, r):
    """encode an integer using a 7-bit+continuation-bit encodeing into an existing list"""
    n = 0
    y = x
    while True:
        n += 1
        y >>= 15
        r.append(0)
        if y == 0:
            break
    v = n
    i = -1
    m = 0
    while n > 0:
        r[i] = x & 32767 | m
        x >>= 15
        i -= 1
        m = 32768
        n -= 1
