summaryrefslogtreecommitdiffstats
path: root/java/src/jni/h5gImp.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2016-08-22 17:05:00 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2016-08-22 17:05:00 (GMT)
commit737bb567355940ec0938ab0bacc0eb18ad4201c7 (patch)
tree1aefa9bd84a886997773107314cc8d0c4c2a10c0 /java/src/jni/h5gImp.c
parentf14e4b3e2061c8fb714413473a65d9d61328b8b7 (diff)
downloadhdf5-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/h5gImp.c')
-rw-r--r--java/src/jni/h5gImp.c126
1 files changed, 65 insertions, 61 deletions
diff --git a/java/src/jni/h5gImp.c b/java/src/jni/h5gImp.c
index a2c0de0..c40ed64 100644
--- a/java/src/jni/h5gImp.c
+++ b/java/src/jni/h5gImp.c
@@ -69,33 +69,30 @@ create_H5G_info_t
jclass cls;
jboolean jmounted;
jint storage_type;
- jobject obj;
+ jobject obj = NULL;
jfieldID fid_storage_type, fid_nlinks, fid_max_corder, fid_mounted;
cls = ENVPTR->FindClass(ENVPAR "hdf/hdf5lib/structs/H5G_info_t");
- if (cls == NULL)
- return NULL;
-
- obj = ENVPTR->AllocObject(ENVPAR cls);
- if (obj == NULL)
- return NULL;
-
- fid_storage_type = ENVPTR->GetFieldID(ENVPAR cls, "storage_type", "I");
- fid_nlinks = ENVPTR->GetFieldID(ENVPAR cls, "nlinks", "J");
- fid_max_corder = ENVPTR->GetFieldID(ENVPAR cls, "max_corder", "J");
- fid_mounted = ENVPTR->GetFieldID(ENVPAR cls, "mounted", "Z");
-
- if (fid_storage_type==NULL || fid_nlinks==NULL || fid_max_corder==NULL || fid_mounted == NULL)
- return NULL;
-
- jmounted = (group_info.mounted==0) ? JNI_FALSE : JNI_TRUE;
- storage_type = (jint)group_info.storage_type;
-
- ENVPTR->SetIntField(ENVPAR obj, fid_storage_type, (jint)storage_type);
- ENVPTR->SetLongField(ENVPAR obj, fid_nlinks, (jlong)group_info.nlinks);
- ENVPTR->SetLongField(ENVPAR obj, fid_max_corder, (jlong)group_info.max_corder);
- ENVPTR->SetBooleanField(ENVPAR obj, fid_mounted, jmounted);
-
+ if (cls != NULL) {
+ obj = ENVPTR->AllocObject(ENVPAR cls);
+ if (obj != NULL) {
+ if ((fid_storage_type = ENVPTR->GetFieldID(ENVPAR cls, "storage_type", "I")) != NULL) {
+ if ((fid_nlinks = ENVPTR->GetFieldID(ENVPAR cls, "nlinks", "J")) != NULL) {
+ if ((fid_max_corder = ENVPTR->GetFieldID(ENVPAR cls, "max_corder", "J")) != NULL) {
+ if ((fid_mounted = ENVPTR->GetFieldID(ENVPAR cls, "mounted", "Z")) != NULL) {
+ jmounted = (group_info.mounted==0) ? JNI_FALSE : JNI_TRUE;
+ storage_type = (jint)group_info.storage_type;
+
+ ENVPTR->SetIntField(ENVPAR obj, fid_storage_type, (jint)storage_type);
+ ENVPTR->SetLongField(ENVPAR obj, fid_nlinks, (jlong)group_info.nlinks);
+ ENVPTR->SetLongField(ENVPAR obj, fid_max_corder, (jlong)group_info.max_corder);
+ ENVPTR->SetBooleanField(ENVPAR obj, fid_mounted, jmounted);
+ }
+ }
+ }
+ }
+ }
+ }
return obj;
} /* end create_H5G_info_t */
@@ -112,13 +109,14 @@ Java_hdf_hdf5lib_H5__1H5Gcreate2
hid_t group_id = -1;
const char *gName;
- PIN_JAVA_STRING(name, gName, -1);
+ PIN_JAVA_STRING(name, gName);
+ if (gName != NULL) {
+ group_id = H5Gcreate2((hid_t)loc_id, gName, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id );
- group_id = H5Gcreate2((hid_t)loc_id, gName, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id );
-
- UNPIN_JAVA_STRING(name, gName);
- if (group_id < 0)
- h5libraryError(env);
+ UNPIN_JAVA_STRING(name, gName);
+ if (group_id < 0)
+ h5libraryError(env);
+ }
return (jlong)group_id;
} /* end Java_hdf_hdf5lib_H5__1H5Gcreate2 */
@@ -153,14 +151,15 @@ Java_hdf_hdf5lib_H5__1H5Gopen2
hid_t group_id = -1;
const char *gName;
- PIN_JAVA_STRING(name, gName, -1);
+ PIN_JAVA_STRING(name, gName);
+ if (gName != NULL) {
+ group_id = H5Gopen2((hid_t)loc_id, gName, (hid_t)access_plist_id );
- group_id = H5Gopen2((hid_t)loc_id, gName, (hid_t)access_plist_id );
+ UNPIN_JAVA_STRING(name, gName);
- UNPIN_JAVA_STRING(name, gName);
-
- if (group_id < 0)
- h5libraryError(env);
+ if (group_id < 0)
+ h5libraryError(env);
+ }
return (jlong)group_id;
} /* end Java_hdf_hdf5lib_H5__1H5Gopen2 */
@@ -192,14 +191,15 @@ JNIEXPORT jobject JNICALL
Java_hdf_hdf5lib_H5_H5Gget_1info
(JNIEnv *env, jclass cls, jlong loc_id)
{
+ jobject obj = NULL;
H5G_info_t group_info;
- if (H5Gget_info((hid_t)loc_id, &group_info) < 0) {
+ if (H5Gget_info((hid_t)loc_id, &group_info) < 0)
h5libraryError(env);
- return NULL;
- } /* end if */
+ else
+ obj = create_H5G_info_t(env, group_info);
- return create_H5G_info_t(env, group_info);
+ return obj;
} /* end Java_hdf_hdf5lib_H5_H5Gget_1info */
/*
@@ -211,22 +211,24 @@ JNIEXPORT jobject JNICALL
Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name
(JNIEnv *env, jclass cls, jlong loc_id, jstring name, jlong lapl_id)
{
+ jobject obj = NULL;
herr_t ret_val = -1;
const char *gName;
H5G_info_t group_info;
- PIN_JAVA_STRING(name, gName, NULL);
+ PIN_JAVA_STRING(name, gName);
+ if (gName != NULL) {
+ ret_val = H5Gget_info_by_name((hid_t)loc_id, gName, &group_info, (hid_t)lapl_id);
- ret_val = H5Gget_info_by_name((hid_t)loc_id, gName, &group_info, (hid_t)lapl_id);
+ UNPIN_JAVA_STRING(name, gName);
- UNPIN_JAVA_STRING(name, gName);
-
- if (ret_val < 0) {
- h5libraryError(env);
- return NULL;
- } /* end if */
+ if (ret_val < 0)
+ h5libraryError(env);
+ else
+ obj = create_H5G_info_t(env, group_info);
+ }
- return create_H5G_info_t(env, group_info);
+ return obj;
} /* end Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name */
/*
@@ -239,25 +241,27 @@ Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx
(JNIEnv *env, jclass cls, jlong loc_id, jstring name, jint index_type,
jint order, jlong n, jlong lapl_id)
{
+ jobject obj = NULL;
herr_t ret_val = -1;
const char *gName;
H5G_info_t group_info;
H5_index_t cindex_type = (H5_index_t)index_type;
H5_iter_order_t corder = (H5_iter_order_t)order;
- PIN_JAVA_STRING(name, gName, NULL);
-
- ret_val = H5Gget_info_by_idx((hid_t)loc_id, gName, cindex_type,
- corder, (hsize_t)n, &group_info, (hid_t)lapl_id);
+ PIN_JAVA_STRING(name, gName);
+ if (gName != NULL) {
+ ret_val = H5Gget_info_by_idx((hid_t)loc_id, gName, cindex_type,
+ corder, (hsize_t)n, &group_info, (hid_t)lapl_id);
- UNPIN_JAVA_STRING(name, gName);
+ UNPIN_JAVA_STRING(name, gName);
- if (ret_val < 0) {
- h5libraryError(env);
- return NULL;
- } /* end if */
+ if (ret_val < 0)
+ h5libraryError(env);
+ else
+ obj = create_H5G_info_t(env, group_info);
+ }
- return create_H5G_info_t(env, group_info);
+ return obj;
} /* end Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx */
/*
@@ -267,7 +271,7 @@ Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Gflush
- (JNIEnv *env, jclass clss, jlong loc_id)
+ (JNIEnv *env, jclass clss, jlong loc_id)
{
if (H5Gflush((hid_t)loc_id) < 0)
h5libraryError(env);
@@ -280,7 +284,7 @@ Java_hdf_hdf5lib_H5_H5Gflush
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Grefresh
- (JNIEnv *env, jclass clss, jlong loc_id)
+ (JNIEnv *env, jclass clss, jlong loc_id)
{
if (H5Grefresh((hid_t)loc_id) < 0)
h5libraryError(env);