#include <stdarg.h>

#include "WUtil.h"

/*
 * This should be written in Rust whenever va_args support improves.
 */
WMPropList *WMCreatePLArray(WMPropList * elem, ...)
{
	WMPropList *plist, *nelem;
	va_list ap;

	plist = WMCreateEmptyPLArray();

	if (!elem)
		return plist;

	WMAddToPLArray(plist, elem);

	va_start(ap, elem);

	while (1) {
		nelem = va_arg(ap, WMPropList *);
		if (!nelem) {
			va_end(ap);
			return plist;
		}
		WMAddToPLArray(plist, elem);
	}
}
