From d643b9e89bd618a75e7676a693c91ab3e11cfbe3 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 20 Mar 2012 17:55:24 +0100 Subject: [PATCH] add isl_band_dup Signed-off-by: Sven Verdoolaege --- isl_band.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/isl_band.c b/isl_band.c index b6624cf..7d05cd6 100644 --- a/isl_band.c +++ b/isl_band.c @@ -30,6 +30,45 @@ __isl_give isl_band *isl_band_alloc(isl_ctx *ctx) return band; } +/* Create a duplicate of the given band. The duplicate refers + * to the same schedule and parent as the input, but does not + * increment their reference counts. + */ +__isl_give isl_band *isl_band_dup(__isl_keep isl_band *band) +{ + int i; + isl_ctx *ctx; + isl_band *dup; + + if (!band) + return NULL; + + ctx = isl_band_get_ctx(band); + dup = isl_band_alloc(ctx); + if (!dup) + return NULL; + + dup->n = band->n; + dup->zero = isl_alloc_array(ctx, int, band->n); + if (!dup->zero) + goto error; + + for (i = 0; i < band->n; ++i) + dup->zero[i] = band->zero[i]; + + dup->pma = isl_union_pw_multi_aff_copy(band->pma); + dup->schedule = band->schedule; + dup->parent = band->parent; + + if (!dup->pma) + goto error; + + return dup; +error: + isl_band_free(dup); + return NULL; +} + /* We not only increment the reference count of the band, * but also that of the schedule that contains this band. * This ensures that the schedule won't disappear while there -- 2.7.4