diff src/ov-fcn-handle.cc @ 6695:c45431c845f3

[project @ 2007-06-07 21:30:39 by dbateman]
author dbateman
date Thu, 07 Jun 2007 21:30:40 +0000
parents 86354a8cd6a7
children 9e32bb109980
line wrap: on
line diff
--- a/src/ov-fcn-handle.cc	Wed Jun 06 06:08:26 2007 +0000
+++ b/src/ov-fcn-handle.cc	Thu Jun 07 21:30:40 2007 +0000
@@ -737,6 +737,7 @@
       H5Tset_size (type_hid, stmp.length () + 1);
       if (type_hid < 0)
 	{
+	  H5Sclose (space_hid);
 	  H5Gclose (group_hid);
 	  return false;
 	}
@@ -837,7 +838,12 @@
 	  H5Aclose (a_id);
 	}
       else
-	retval = false;
+	{
+	  H5Sclose (space_hid);
+	  H5Tclose (type_hid);
+	  H5Gclose (group_hid);
+	  return false;
+	}
 
       H5Sclose (space_hid);
       hdims[0] = 1;
@@ -934,8 +940,10 @@
 
   if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, nm_tmp) < 0)
     {
+      H5Tclose (st_id);
       H5Sclose (space_hid);
       H5Tclose (type_hid);
+      H5Dclose (data_hid);
       H5Gclose (group_hid);
       return false;
     }
@@ -949,21 +957,26 @@
 
       if (data_hid < 0)
 	{
+	  H5Sclose (space_hid);
+	  H5Tclose (type_hid);
 	  H5Gclose (group_hid);
 	  return false;
 	}
 
+      H5Tclose (type_hid);
       type_hid = H5Dget_type (data_hid);
       type_class_hid = H5Tget_class (type_hid);
 
       if (type_class_hid != H5T_STRING)
 	{
+	  H5Sclose (space_hid);
 	  H5Tclose (type_hid);
 	  H5Dclose (data_hid);
 	  H5Gclose (group_hid);
 	  return false;
 	}
 
+      H5Sclose (space_hid);
       space_hid = H5Dget_space (data_hid);
       rank = H5Sget_simple_extent_ndims (space_hid);
 
@@ -994,11 +1007,14 @@
 
       if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, fcn_tmp) < 0)
 	{
+	  H5Tclose (st_id);
 	  H5Sclose (space_hid);
 	  H5Tclose (type_hid);
+	  H5Dclose (data_hid);
 	  H5Gclose (group_hid);
 	  return false;
 	}
+      H5Tclose (st_id);
       H5Dclose (data_hid);
 
       symbol_table *local_sym_tab = 0;
@@ -1081,9 +1097,6 @@
 	    }
 	}
 
-      H5Tclose (st_id);
-      H5Gclose (group_hid);
-
       if (success)
 	{
 	  unwind_protect::begin_frame ("anon_hdf5_load");
@@ -1133,6 +1146,7 @@
       hid_t attr_id = H5Aopen_name (group_hid, "OCTAVEROOT");
       if (attr_id >= 0)
 	{
+	  H5Tclose (type_hid);
 	  type_hid = H5Aget_type (attr_id);
 	  type_class_hid = H5Tget_class (type_hid);
 
@@ -1149,33 +1163,41 @@
 		success = false;
 	      else
 		octaveroot = root_tmp;
+
+	      H5Tclose (st_id);
 	    }
 
 	  H5Aclose (attr_id);
 	}
 
-      attr_id = H5Aopen_name (group_hid, "FILE");
-      if (attr_id >= 0)
+      if (success)
 	{
-	  type_hid = H5Aget_type (attr_id);
-	  type_class_hid = H5Tget_class (type_hid);
+	  attr_id = H5Aopen_name (group_hid, "FILE");
+	  if (attr_id >= 0)
+	    {
+	      H5Tclose (type_hid);
+	      type_hid = H5Aget_type (attr_id);
+	      type_class_hid = H5Tget_class (type_hid);
 
-	  if (type_class_hid != H5T_STRING)
-	    success = false;
-	  else
-	    {
-	      slen = H5Tget_size (type_hid);
-	      st_id = H5Tcopy (H5T_C_S1);
-	      H5Tset_size (st_id, slen);
-	      OCTAVE_LOCAL_BUFFER (char, path_tmp, slen);
-
-	      if (H5Aread (attr_id, st_id, path_tmp) < 0)
+	      if (type_class_hid != H5T_STRING)
 		success = false;
 	      else
-		fpath = path_tmp;
+		{
+		  slen = H5Tget_size (type_hid);
+		  st_id = H5Tcopy (H5T_C_S1);
+		  H5Tset_size (st_id, slen);
+		  OCTAVE_LOCAL_BUFFER (char, path_tmp, slen);
+
+		  if (H5Aread (attr_id, st_id, path_tmp) < 0)
+		    success = false;
+		  else
+		    fpath = path_tmp;
+
+		  H5Tclose (st_id);
+		}
+
+	      H5Aclose (attr_id);
 	    }
-
-	  H5Aclose (attr_id);
 	}
 
       // restore error reporting:
@@ -1184,6 +1206,10 @@
       success = (success ? set_fcn (octaveroot, fpath) : success);
     }
 
+  H5Tclose (type_hid);
+  H5Sclose (space_hid);
+  H5Gclose (group_hid);
+
   return success;
 }