From 50f718fdc7131d5c781434489a5e6efee27f45e3 Mon Sep 17 00:00:00 2001 From: Han Hu Date: Thu, 12 May 2016 14:52:15 +0800 Subject: [PATCH] Close unused resource in dscreate and dsread. Otherwise, the file will not be close when close() is called. See the following for Delayed close, which is close dataset after exe terminate: https://www.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-Close change tab to 4 blanks --- modules/hdf/src/hdf5.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/hdf/src/hdf5.cpp b/modules/hdf/src/hdf5.cpp index 4ae4b8bee..7f13398f7 100644 --- a/modules/hdf/src/hdf5.cpp +++ b/modules/hdf/src/hdf5.cpp @@ -536,7 +536,7 @@ void HDF5Impl::dscreate( const int n_dims, const int* sizes, const int type, } // create data - H5Dcreate( m_h5_file_id, dslabel.c_str(), dstype, + hid_t dsdata = H5Dcreate( m_h5_file_id, dslabel.c_str(), dstype, dspace, H5P_DEFAULT, dsdcpl, H5P_DEFAULT ); if ( channs > 1 ) @@ -548,6 +548,7 @@ void HDF5Impl::dscreate( const int n_dims, const int* sizes, const int type, H5Pclose( dsdcpl ); H5Sclose( dspace ); + H5Dclose( dsdata ); } // overload @@ -663,6 +664,7 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel, delete [] mxdims; delete [] foffset; + H5Tclose (h5type ); H5Tclose( dstype ); H5Sclose( dspace ); H5Sclose( fspace );