aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2010-04-02 13:54:30 +0200
committerThomas White <taw@bitwiz.org.uk>2010-04-02 13:56:38 +0200
commitd430dcb7d2d1c6af47888bfc70dcbfd55b32cf1a (patch)
treef8532136562c086865153e8b66d6d18c18a87432
parent0f58e0fc3418fdd5a97de533e2e2818b8d81c941 (diff)
Add HDF5 group cleanup
-rw-r--r--src/hdf5-file.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/hdf5-file.c b/src/hdf5-file.c
index ebc967ac..af379d38 100644
--- a/src/hdf5-file.c
+++ b/src/hdf5-file.c
@@ -98,11 +98,39 @@ int hdfile_get_height(struct hdfile *f)
}
+static void cleanup(hid_t fh)
+{
+ int n_objs, n_ids, i;
+ hid_t *ids;
+
+ n_objs = H5Fget_obj_count(fh, H5F_OBJ_ALL);
+ if ( n_objs <= 0 ) return;
+
+ ids = malloc(n_objs * sizeof(hid_t));
+ n_ids = H5Fget_obj_ids(fh, H5F_OBJ_ALL, n_objs, ids);
+ for (i=0; i<n_ids; i++ ) {
+
+ hid_t id;
+ H5I_type_t type;
+
+ id = ids[i];
+ type = H5Iget_type(id);
+
+ if ( type == H5I_GROUP ) H5Gclose(id);
+
+ }
+
+ free(ids);
+}
+
+
void hdfile_close(struct hdfile *f)
{
if ( f->data_open ) {
H5Dclose(f->dh);
}
+ cleanup(f->fh);
+
H5Fclose(f->fh);
free(f);
}