From 4c07e22ae4e3ec1d5029512ae2ea61a040c215db Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Tue, 21 Apr 2015 13:52:43 -0600 Subject: [PATCH] Progress working towards [NCF-329] --- CMakeLists.txt | 22 +++++++++++++++++++--- config.h.cmake.in | 1 + libsrc4/nc4file.c | 9 ++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7167cd56..ca2b68792 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -461,9 +461,8 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4) # Find out if HDF5 was built with parallel support. # Do that by checking for the targets H5Pget_fapl_mpiposx and # H5Pget_fapl_mpio in ${HDF5_LIB}. - CHECK_LIBRARY_EXISTS(${HDF5_hdf5_LIBRARY} H5Pget_fapl_mpiposix "" HDF5_IS_PARALLEL_MPIPOSIX) - CHECK_LIBRARY_EXISTS(${HDF5_hdf5_LIBRARY} H5Pget_fapl_mpio "" HDF5_IS_PARALLEL_MPIO) - + CHECK_LIBRARY_EXISTS(hdf5 H5Pget_fapl_mpiposix "" HDF5_IS_PARALLEL_MPIPOSIX) + CHECK_LIBRARY_EXISTS(hdf5 H5Pget_fapl_mpio "" HDF5_IS_PARALLEL_MPIO) IF(HDF5_IS_PARALLEL_MPIPOSIX OR HDF5_IS_PARALLEL_MPIO) SET(HDF5_IS_PARALLEL ON) ENDIF() @@ -483,6 +482,9 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4) ENDIF(NOT MSVC) + CHECK_LIBRARY_EXISTS(hdf5 H5free_memory "" HDF5_HAS_H5FREE) + + # Assert HDF5 version. SET(HDF5_VERSION_REQUIRED 1.8.10) @@ -549,6 +551,20 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4) ENDIF() SET(USE_ZLIB ON) INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS}) + + ## + # Check to see if libhdf5 contains + # 'H5free_memory'. + ## +# CHECK_C_SOURCE_COMPILES(" +# #include +# int main() {H5free_memory(NULL);}" HDF5_HAS_H5FREE) +# CHECK_SYMBOL_EXISTS(H5free_memory "H5public.h" HDF5_HAS_H5FREE) +# CHECK_LIBRARY_EXISTS(hdf5 H5free_memory "-L${HDF5_hdf5_LIBRARY}" HDF5_HAS_H5FREE) +# MESSAGE(STATUS "HDF5_HAS_H5FREE: ${HDF5_HAS_H5FREE}") + + + ENDIF() # Option to Build DAP Client diff --git a/config.h.cmake.in b/config.h.cmake.in index ec2761728..07db7b554 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -88,6 +88,7 @@ are set when opening a binary file on Windows. */ #cmakedefine USE_FFIO 1 #cmakedefine USE_PARALLEL_POSIX 1 #cmakedefine USE_PARALLEL_MPIO 1 +#cmakedefine HDF5_HAS_H5FREE 1 #cmakedefine USE_PARALLEL 1 #cmakedefine USE_PNETCDF 1 #cmakedefine USE_MMAP 1 diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index 35a8ccb86..3292880ad 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -1284,12 +1284,19 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name) } #ifndef JNA + /* Free the member name (which HDF5 allocated for us). */ /* On Windows using the microsoft runtime, it is an error - for one library to free memory allocated by a different library. */ + for one library to free memory allocated by a different library. + IF it is available, we should use H5free_memory*/ + +#ifdef HDF5_HAS_H5FREE + if(member_name != NULL) H5free_memory(member_name); +#else #ifndef _MSC_VER if(member_name != NULL) free(member_name); #endif +#endif #endif member_name = NULL; }