Blame isl-0.16.1/isl_multi_coalesce.c

Packit fb9d21
/*
Packit fb9d21
 * Copyright 2013      Ecole Normale Superieure
Packit fb9d21
 *
Packit fb9d21
 * Use of this software is governed by the MIT license
Packit fb9d21
 *
Packit fb9d21
 * Written by Sven Verdoolaege,
Packit fb9d21
 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
Packit fb9d21
 */
Packit fb9d21
Packit fb9d21
#include <isl_multi_macro.h>
Packit fb9d21
Packit fb9d21
/* Coalesce the elements of "multi".
Packit fb9d21
 *
Packit fb9d21
 * Note that such coalescing does not change the meaning of "multi"
Packit fb9d21
 * so there is no need to cow.  We do need to be careful not to
Packit fb9d21
 * destroy any other copies of "multi" in case of failure.
Packit fb9d21
 */
Packit fb9d21
__isl_give MULTI(BASE) *FN(MULTI(BASE),coalesce)(__isl_take MULTI(BASE) *multi)
Packit fb9d21
{
Packit fb9d21
	int i;
Packit fb9d21
Packit fb9d21
	if (!multi)
Packit fb9d21
		return NULL;
Packit fb9d21
Packit fb9d21
	for (i = 0; i < multi->n; ++i) {
Packit fb9d21
		EL *el = FN(EL,copy)(multi->p[i]);
Packit fb9d21
		el = FN(EL,coalesce)(el);
Packit fb9d21
		if (!el)
Packit fb9d21
			return FN(MULTI(BASE),free)(multi);
Packit fb9d21
		FN(EL,free)(multi->p[i]);
Packit fb9d21
		multi->p[i] = el;
Packit fb9d21
	}
Packit fb9d21
Packit fb9d21
	return multi;
Packit fb9d21
}