From 0c59aae9f850bc3cea66e3fb6e70ad15d4b120ef Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 3 Jul 2011 19:56:48 +0200 Subject: [PATCH] isl_schedule: don't let users get access to internal isl_band_lists We have been careful to keep the isl_schedule alive whenever the user is holding on to an isl_band, but if the user only has a reference to an isl_band_list inside the schedule, then the schedule can still disappear. We therefore hand out duplicates of internal lists. These duplicates contain copies of the isl_bands and these outside references keep the schedule alive. Signed-off-by: Sven Verdoolaege --- isl_band.c | 3 ++- isl_schedule.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/isl_band.c b/isl_band.c index 1613621..e4fbf93 100644 --- a/isl_band.c +++ b/isl_band.c @@ -10,6 +10,7 @@ #include #include +#include isl_ctx *isl_band_get_ctx(__isl_keep isl_band *band) { @@ -69,7 +70,7 @@ __isl_give isl_band_list *isl_band_get_children( if (!band->children) isl_die(isl_band_get_ctx(band), isl_error_invalid, "band has no children", return NULL); - return isl_band_list_copy(band->children); + return isl_band_list_dup(band->children); } int isl_band_n_member(__isl_keep isl_band *band) diff --git a/isl_schedule.c b/isl_schedule.c index a5df67f..56486d8 100644 --- a/isl_schedule.c +++ b/isl_schedule.c @@ -23,6 +23,7 @@ #include #include #include +#include /* * The scheduling algorithm implemented in this file was inspired by @@ -2706,7 +2707,7 @@ __isl_give isl_band_list *isl_schedule_get_band_forest( return NULL; if (!schedule->band_forest) schedule->band_forest = construct_forest(schedule); - return isl_band_list_copy(schedule->band_forest); + return isl_band_list_dup(schedule->band_forest); } static __isl_give isl_printer *print_band_list(__isl_take isl_printer *p, -- 2.7.4