Index: /trunk/cgi-bin/IPDB.pm
===================================================================
--- /trunk/cgi-bin/IPDB.pm	(revision 772)
+++ /trunk/cgi-bin/IPDB.pm	(revision 773)
@@ -479,4 +479,32 @@
 
 } # end _deleteCascade()
+
+
+## IPDB::_getChildren()
+# Recursive sub to retrieve a flat list of suballocations
+# Takes the root parent ID, master ID, reference to push results into, and the CIDR
+# range to restrict results to
+sub _getChildren {
+  my $dbh = shift;
+  my $id = shift;
+  my $master = shift;
+  my $retlist = shift;  # better than trying to return complex structures recursively. Ow.
+  my $cidr = shift;
+
+  if (!$cidr) {
+    my $bd = getBlockData($dbh, $id);
+    $cidr = $bd->{cidr};
+  }
+
+  my $sth = $dbh->prepare(q(
+	SELECT id,cidr,type FROM allocations
+	WHERE parent_id = ? AND master_id = ? AND cidr <<= ?
+	) );
+  $sth->execute($id, $master, $cidr);
+  while (my $row = $sth->fetchrow_hashref) {
+    push @$retlist, $row;
+    _getChildren($dbh, $row->{id}, $master, $retlist, $cidr);
+  }
+} # end _getChildren()
 
 
@@ -2072,28 +2100,4 @@
   my $delfbsth = $dbh->prepare("DELETE FROM freeblocks WHERE parent_id = ? AND cidr <<= ?");
 
-##fixme:  turn this into a public/top-level sub?
-  sub getchildren {
-    my $dbh = shift;
-    my $id = shift;
-    my $master = shift;
-    my $retlist = shift;  # better than trying to return complex structures recursively. Ow.
-    my $cidr = shift;
-
-    if (!$cidr) {
-      my $bd = getBlockData($dbh, $id);
-      $cidr = $bd->{cidr};
-    }
-
-    my $sth = $dbh->prepare(q(
-	SELECT id,cidr,type FROM allocations
-	WHERE parent_id = ? AND master_id = ? AND cidr <<= ?
-	) );
-    $sth->execute($id, $master, $cidr);
-    while (my $row = $sth->fetchrow_hashref) {
-      push @$retlist, $row;
-      getchildren($dbh, $row->{id}, $master, $retlist, $cidr);
-    }
-  }
-
   my @ret;
   my @newfreelist;
@@ -2114,5 +2118,5 @@
       # the block we're munging
       push @clist, { id => $id, type => $binfo->{type}, cidr => $binfo->{block} };
-      getchildren($dbh, $id, $binfo->{master_id}, \@clist, $newfree);
+      _getChildren($dbh, $id, $binfo->{master_id}, \@clist, $newfree);
 
       foreach my $goner (@clist) {
