isl_schedule: don't let users get access to internal isl_band_lists
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 3 Jul 2011 17:56:48 +0000 (19:56 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 5 Jul 2011 17:55:55 +0000 (19:55 +0200)
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 <skimo@kotnet.org>
isl_band.c
isl_schedule.c

index 1613621..e4fbf93 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <isl_band_private.h>
 #include <isl_schedule_private.h>
+#include <isl_list_private.h>
 
 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)
index a5df67f..56486d8 100644 (file)
@@ -23,6 +23,7 @@
 #include <isl_qsort.h>
 #include <isl_schedule_private.h>
 #include <isl_band_private.h>
+#include <isl_list_private.h>
 
 /*
  * 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,