def iterableToArray(param, type):
    """Convert an iterable to a ctypes array of type.
    Returns tuple of array, length."""
    length = getattr(param, '_length_', None)
    if length is None:
        length = len(param)
        arr = (type * length)(*param)
    else:
        arr = param
    return arr, length
