Index: trunk/Ohana/src/libdvo/include/dvo.h
===================================================================
--- trunk/Ohana/src/libdvo/include/dvo.h	(revision 14290)
+++ trunk/Ohana/src/libdvo/include/dvo.h	(revision 14401)
@@ -153,4 +153,5 @@
 typedef struct {
   int Nregions;
+  int ownElements; 				  /* does this list own filename, regions? */
   char **filename;
   SkyRegion **regions;
@@ -428,5 +429,5 @@
 SkyList   *SkyListChildrenByBounds PROTO((SkyTable *table, int No, int depth, double Rmin, double Rmax, double Dmin, double Dmax));
 int        SkyListMerge     	   PROTO((SkyList **outlist, SkyList *newlist));
-int        SkyListFree             PROTO((SkyList *list, int ELEMENTS));
+int        SkyListFree             PROTO((SkyList *list));
 int        SkyTableFree            PROTO((SkyTable *table));
 int        SkyListSetFilenames     PROTO((SkyList *list, char *path, char *ext));
Index: trunk/Ohana/src/libdvo/src/skyregion_ops.c
===================================================================
--- trunk/Ohana/src/libdvo/src/skyregion_ops.c	(revision 14290)
+++ trunk/Ohana/src/libdvo/src/skyregion_ops.c	(revision 14401)
@@ -19,4 +19,5 @@
   ALLOCATE (list[0].filename,  char *, 1);
   list[0].Nregions = 0;
+  list[0].ownElements = FALSE; // this list is only holding a view to the elements
 
   region = table[0].regions;
@@ -65,4 +66,5 @@
   ALLOCATE (list[0].filename, char *, NREGIONS);
   list[0].Nregions = N;
+  list[0].ownElements = FALSE; // this list is only holding a view to the elements
 
   region = table[0].regions;
@@ -99,4 +101,5 @@
   ALLOCATE (list[0].filename,  char *, NREGIONS);
   list[0].Nregions = N;
+  list[0].ownElements = FALSE; // this list is only holding a view to the elements
 
   region = table[0].regions;
@@ -232,5 +235,5 @@
     }
     list[0].Nregions = Ns;
-    SkyListFree (extra, FALSE);
+    SkyListFree (extra);
   } else {
     list = SkyListChildrenByBounds (table, -1, depth, Rmin, Rmax, Dmin, Dmax);
@@ -253,4 +256,5 @@
   ALLOCATE (list[0].regions, SkyRegion *, NNEW);
   ALLOCATE (list[0].filename, char *, NNEW);
+  list[0].ownElements = FALSE; // this list is only holding a view to the elements
 
   region = table[0].regions;
@@ -289,5 +293,5 @@
       }
       Nnew += children[0].Nregions;
-      SkyListFree (children, FALSE);
+      SkyListFree (children);
     } else {
       list[0].regions[Nnew] = &region[i];
@@ -332,5 +336,5 @@
 }
 
-int SkyListFree (SkyList *list, int ELEMENTS) {
+int SkyListFree (SkyList *list) {
 
   int i;
@@ -339,5 +343,5 @@
   if (list == NULL) return (TRUE);
   if (list[0].regions != NULL) {
-    if (ELEMENTS) {
+    if (list[0].ownElements) {
       for (i = 0; i < list[0].Nregions; i++) {
 	if (list[0].filename[i] != NULL) {
@@ -384,4 +388,5 @@
 	ALLOCATE (list[0].regions, SkyRegion *, 1);
 	ALLOCATE (list[0].filename, char *, 1);
+	list[0].ownElements = FALSE; // this list is only holding a view to the elements
 	list[0].Nregions = 0;
 	*outlist = list;
@@ -412,120 +417,2 @@
     return (TRUE);
 }
-
-# if (0)
-
-/* find regions contained within rectangular region  c1 - c2 */
-SkyRegion **SkyFindArea (SkyRegion *db, SkyCoord c1, SkyCoord c2, int *nlist) {
-
-  int Nlist;
-  SkyRegion *list, *new, *sub;
-
-  while (c1.r > 360.0) c1.r -= 360.0;
-  while (c1.r <   0.0) c1.r += 360.0;
-  while (c2.r > 360.0) c2.r -= 360.0;
-  while (c2.r <   0.0) c2.r += 360.0;
-
-  /* check on c1.r > c2.r : cross boundary */
-  if (c1.r > c2.r) {
-    c0 = c2; c0.r = 360.0;
-    list = SkyFindArea (db, c1, c0, &Nlist);
-    c0 = c1; c0.r = 0.0;
-    new  = SkyFindArea (db, c0, c2, &Nnew);
-    REALLOCATE (list, SkyRegion *, MAX (1, Nlist + Nnew));
-    memcpy (&list[Nlist], new, Nnew*sizeof(SkyRegion *));
-    free (new);
-    Nlist += Nnew;
-    *nlist = Nlist;
-    return (list);
-  }    
-
-  Ns = 0;
-  Ne = 1;
-  Nlist = 1;
-  ALLOCATE (list, SkyRegion *, Nlist);
-  list[0] = &region[0];
-  getchild = region[0].child;
-
-  while (getchild) {
-
-    getchild = FALSE;
-    Nnew = 0;
-    NNEW = 100;
-    ALLOCATE (new, SkyRegion *, NNEW);
-
-    for (i = Ns; i < Ne; i++) {
-      children = SkyFindChildren(db, list[i], c1, c2, &Nchildren);
-      if (children == NULL) continue;
-      if (Nnew + Nchildren >= NNEW) {
-	NNEW += 100;
-	REALLOCATE (new, SkyRegion *, NNEW);
-      }
-      for (i = 0; i < Nchildren; i++) {
-	getchild |= children[i][0].child;
-	new[Nnew] = children[i];
-	Nnew++;
-      }
-      free (children);
-    }
-
-    REALLOCATE (list, SkyRegion *, Nlist + Nnew);
-    memcpy (&list[Nlist], new, Nnew*sizeof(SkyRegion *));
-    free (new);
-    Nlist += Nnew;
-  }
-  return (list);
-  *nlist = Nlist;
-}
-
-/* find all children of the given sky region */
-SkyRegion **SkyFindChildren (SkyRegion *db, SkyRegion *parent, SkyCoord c1, SkyCoord c2, int *Nchildren) {
-
-  int i, Ns, Ne, Nregion, NREGIONS;
-  SkyRegion **region;
-  
-  *Nchildren = 0;
-  if (!parent[0].child) return (NULL);
-
-  Ns = parent[0].childS;
-  Ne = parent[0].childE;
-
-  Nregion = 0;
-  NREGIONS = 100;
-  ALLOCATE (region, SkyRegion *, NREGIONS);
-
-  for (i = Ns; i < Ne; i++) {
-    if (region[i].Rmax < c1.r) continue;
-    if (region[i].Rmin > c2.r) continue;
-    if (region[i].Dmax < c1.d) continue;
-    if (region[i].Dmin > c2.d) continue;
-    region[Nregion] = &region[i];
-    Nregion++;
-    if (Nregion == NREGIONS) {
-      NREGIONS += 100;
-      REALLOCATE (region, SkyRegion *, NREGIONS);
-    }      
-  }
-  *Nchildren = Nregion; 
-  return (region);
-}
-
-/* region is pointer to entry in db */
-SkyRegion *SkyExtend (SkyRegion *db, SkyRegion *region) {
-
-  fprintf (stderr, "not implemented\n");
-
-}
-
-/* region is pointer to entry in db */
-SkyRegion *SkyContract (SkyRegion *db, SkyRegion *region) {
-
-  fprintf (stderr, "not implemented\n");
-
-}
-
-SkyRegion *SkyFindGCircle (SkyRegion *db, SkyCoord c1, SkyCoord c2) {
-
-  fprintf (stderr, "not implemented\n");
-
-}
-# endif 
