From d430dcb7d2d1c6af47888bfc70dcbfd55b32cf1a Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 2 Apr 2010 13:54:30 +0200 Subject: Add HDF5 group cleanup --- src/hdf5-file.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/hdf5-file.c') 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; idata_open ) { H5Dclose(f->dh); } + cleanup(f->fh); + H5Fclose(f->fh); free(f); } -- cgit v1.2.3