diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2016-08-22 17:05:00 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2016-08-22 17:05:00 (GMT) |
commit | 737bb567355940ec0938ab0bacc0eb18ad4201c7 (patch) | |
tree | 1aefa9bd84a886997773107314cc8d0c4c2a10c0 /java/src/jni/h5fImp.c | |
parent | f14e4b3e2061c8fb714413473a65d9d61328b8b7 (diff) | |
download | hdf5-737bb567355940ec0938ab0bacc0eb18ad4201c7.zip hdf5-737bb567355940ec0938ab0bacc0eb18ad4201c7.tar.gz hdf5-737bb567355940ec0938ab0bacc0eb18ad4201c7.tar.bz2 |
[svn-r30313] HDFFV-9972: unsatisfied link error under debug on Windows.
Added windows name suffix for debug to CMake cmd_arg for examples and test.
Fix issues discovered under debug testing;
Create a version of H5Iget_name that correctly returns the name.
Rework PIN_JAVA_STRING macro and usage to eliminate possible memory leaks by using if-else instead of mid-routine return.
Update example to use new H5Iget_name API.
Tested: windows under debug
Diffstat (limited to 'java/src/jni/h5fImp.c')
-rw-r--r-- | java/src/jni/h5fImp.c | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c index 33a5932..5862ae7 100644 --- a/java/src/jni/h5fImp.c +++ b/java/src/jni/h5fImp.c @@ -45,14 +45,15 @@ Java_hdf_hdf5lib_H5__1H5Fopen hid_t status = -1; const char *fileName; - PIN_JAVA_STRING(name, fileName, -1); + PIN_JAVA_STRING(name, fileName); + if (fileName != NULL) { + status = H5Fopen(fileName, (unsigned)flags, (hid_t)access_id ); - status = H5Fopen(fileName, (unsigned)flags, (hid_t)access_id ); + UNPIN_JAVA_STRING(name, fileName); - UNPIN_JAVA_STRING(name, fileName); - - if (status < 0) - h5libraryError(env); + if (status < 0) + h5libraryError(env); + } return (jlong)status; } /* end Java_hdf_hdf5lib_H5__1H5Fopen */ @@ -69,14 +70,15 @@ Java_hdf_hdf5lib_H5__1H5Fcreate hid_t status = -1; const char *fileName; - PIN_JAVA_STRING(name, fileName, -1); + PIN_JAVA_STRING(name, fileName); + if (fileName != NULL) { + status = H5Fcreate(fileName, (unsigned)flags, create_id, access_id); - status = H5Fcreate(fileName, (unsigned)flags, create_id, access_id); + UNPIN_JAVA_STRING(name, fileName); - UNPIN_JAVA_STRING(name, fileName); - - if (status < 0) - h5libraryError(env); + if (status < 0) + h5libraryError(env); + } return (jlong)status; } /* end Java_hdf_hdf5lib_H5__1H5Fcreate */ @@ -152,16 +154,17 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5 htri_t bval = JNI_FALSE; const char *fileName; - PIN_JAVA_STRING(name, fileName, JNI_FALSE); - - bval = H5Fis_hdf5(fileName); + PIN_JAVA_STRING(name, fileName); + if (fileName != NULL) { + bval = H5Fis_hdf5(fileName); - UNPIN_JAVA_STRING(name, fileName); + UNPIN_JAVA_STRING(name, fileName); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + } return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Fis_1hdf5 */ @@ -251,14 +254,15 @@ Java_hdf_hdf5lib_H5_H5Fmount herr_t status = -1; const char *fileName; - PIN_JAVA_STRING(name, fileName, -1); - - status = H5Fmount((hid_t)loc_id, fileName, (hid_t)child_id, (hid_t)plist_id); + PIN_JAVA_STRING(name, fileName); + if (fileName != NULL) { + status = H5Fmount((hid_t)loc_id, fileName, (hid_t)child_id, (hid_t)plist_id); - UNPIN_JAVA_STRING(name, fileName); + UNPIN_JAVA_STRING(name, fileName); - if (status < 0) - h5libraryError(env); + if (status < 0) + h5libraryError(env); + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Fmount */ @@ -275,14 +279,15 @@ Java_hdf_hdf5lib_H5_H5Funmount herr_t status = -1; const char *fileName; - PIN_JAVA_STRING(name, fileName, -1); + PIN_JAVA_STRING(name, fileName); + if (fileName != NULL) { + status = H5Funmount((hid_t)loc_id, fileName); - status = H5Funmount((hid_t)loc_id, fileName); + UNPIN_JAVA_STRING(name, fileName); - UNPIN_JAVA_STRING(name, fileName); - - if (status < 0) - h5libraryError(env); + if (status < 0) + h5libraryError(env); + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Funmount */ |