diff --git a/libhdf5/hdf5file.c b/libhdf5/hdf5file.c index 9f453c35e..cf61f08ed 100644 --- a/libhdf5/hdf5file.c +++ b/libhdf5/hdf5file.c @@ -42,6 +42,10 @@ static const NC_reservedatt NC_reserved[NRESERVED] = { {NC3_STRICT_ATT_NAME, READONLYFLAG}, /*_nc3_strict*/ }; +/* Forward */ +static int NC4_enddef(int ncid); +static void dumpopenobjects(NC_FILE_INFO_T* h5); + /* These hold the file caching settings for the library. */ size_t nc4_chunk_cache_size = CHUNK_CACHE_SIZE; /**< Default chunk cache size. */ size_t nc4_chunk_cache_nelems = CHUNK_CACHE_NELEMS; /**< Default chunk cache number of elements. */ @@ -142,52 +146,6 @@ sync_netcdf4_file(NC_FILE_INFO_T *h5) return NC_NOERR; } -/** - * @internal Output a list of still-open objects in the HDF5 - * file. This is only called if the file fails to close cleanly. - * - * @param h5 Pointer to file info. - * - * @author Dennis Heimbigner - */ -static void -dumpopenobjects(NC_FILE_INFO_T* h5) -{ - NC_HDF5_FILE_INFO_T *hdf5_info; - int nobjs; - - assert(h5 && h5->format_file_info); - hdf5_info = (NC_HDF5_FILE_INFO_T *)h5->format_file_info; - - nobjs = H5Fget_obj_count(hdf5_info->hdfid, H5F_OBJ_ALL); - - /* Apparently we can get an error even when nobjs == 0 */ - if(nobjs < 0) { - return; - } else if(nobjs > 0) { - char msg[1024]; - int logit = 0; - /* If the close doesn't work, probably there are still some HDF5 - * objects open, which means there's a bug in the library. So - * print out some info on to help the poor programmer figure it - * out. */ - snprintf(msg,sizeof(msg),"There are %d HDF5 objects open!", nobjs); -#ifdef LOGGING -#ifdef LOGOPEN - LOG((0, msg)); - logit = 1; -#endif -#else - fprintf(stdout,"%s\n",msg); - logit = 0; -#endif - reportopenobjects(logit,hdf5_info->hdfid); - fflush(stderr); - } - - return; -} - /** * @internal This function will free all allocated metadata memory, * and close the HDF5 file. @@ -279,6 +237,52 @@ nc4_close_netcdf4_file(NC_FILE_INFO_T *h5, int abort, int extractmem) return NC_NOERR; } +/** + * @internal Output a list of still-open objects in the HDF5 + * file. This is only called if the file fails to close cleanly. + * + * @param h5 Pointer to file info. + * + * @author Dennis Heimbigner + */ +static void +dumpopenobjects(NC_FILE_INFO_T* h5) +{ + NC_HDF5_FILE_INFO_T *hdf5_info; + int nobjs; + + assert(h5 && h5->format_file_info); + hdf5_info = (NC_HDF5_FILE_INFO_T *)h5->format_file_info; + + nobjs = H5Fget_obj_count(hdf5_info->hdfid, H5F_OBJ_ALL); + + /* Apparently we can get an error even when nobjs == 0 */ + if(nobjs < 0) { + return; + } else if(nobjs > 0) { + char msg[1024]; + int logit = 0; + /* If the close doesn't work, probably there are still some HDF5 + * objects open, which means there's a bug in the library. So + * print out some info on to help the poor programmer figure it + * out. */ + snprintf(msg,sizeof(msg),"There are %d HDF5 objects open!", nobjs); +#ifdef LOGGING +#ifdef LOGOPEN + LOG((0, msg)); + logit = 1; +#endif +#else + fprintf(stdout,"%s\n",msg); + logit = 0; +#endif + reportopenobjects(logit,hdf5_info->hdfid); + fflush(stderr); + } + + return; +} + /** * Set chunk cache size. Only affects files opened/created *after* it * is called. @@ -457,6 +461,26 @@ NC4_redef(int ncid) return NC_NOERR; } +/** + * @internal For netcdf-4 files, this just calls nc_enddef, ignoring + * the extra parameters. + * + * @param ncid File and group ID. + * @param h_minfree Ignored for netCDF-4 files. + * @param v_align Ignored for netCDF-4 files. + * @param v_minfree Ignored for netCDF-4 files. + * @param r_align Ignored for netCDF-4 files. + * + * @return ::NC_NOERR No error. + * @author Ed Hartnett + */ +int +NC4__enddef(int ncid, size_t h_minfree, size_t v_align, + size_t v_minfree, size_t r_align) +{ + return NC4_enddef(ncid); +} + /** * @internal Take the file out of define mode. This is called * automatically for netcdf-4 files, if the user forgets. @@ -494,26 +518,6 @@ NC4_enddef(int ncid) return nc4_enddef_netcdf4_file(nc4_info); } -/** - * @internal For netcdf-4 files, this just calls nc_enddef, ignoring - * the extra parameters. - * - * @param ncid File and group ID. - * @param h_minfree Ignored for netCDF-4 files. - * @param v_align Ignored for netCDF-4 files. - * @param v_minfree Ignored for netCDF-4 files. - * @param r_align Ignored for netCDF-4 files. - * - * @return ::NC_NOERR No error. - * @author Ed Hartnett - */ -int -NC4__enddef(int ncid, size_t h_minfree, size_t v_align, - size_t v_minfree, size_t r_align) -{ - return NC4_enddef(ncid); -} - /** * @internal Flushes all buffers associated with the file, after * writing all changed metadata. This may only be called in data mode.