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/h5lImp.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/h5lImp.c')
-rw-r--r-- | java/src/jni/h5lImp.c | 445 |
1 files changed, 218 insertions, 227 deletions
diff --git a/java/src/jni/h5lImp.c b/java/src/jni/h5lImp.c index eecb1cd..473b1c7 100644 --- a/java/src/jni/h5lImp.c +++ b/java/src/jni/h5lImp.c @@ -52,14 +52,15 @@ Java_hdf_hdf5lib_H5_H5Lcopy const char *lCurName; const char *lDstName; - PIN_JAVA_STRING_TWO0(cur_name, lCurName, dst_name, lDstName); + PIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + if (lCurName != NULL && lDstName != NULL) { + status = H5Lcopy((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); - status = H5Lcopy((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); - UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); - - if (status < 0) - h5libraryError(env); + if (status < 0) + h5libraryError(env); + } } /* end Java_hdf_hdf5lib_H5_H5Lcopy */ /* @@ -77,14 +78,15 @@ Java_hdf_hdf5lib_H5_H5Lcreate_1external const char *lCurName; const char *lDstName; - PIN_JAVA_STRING_THREE0(file_name, lFileName, cur_name, lCurName, dst_name, lDstName); - - status = H5Lcreate_external(lFileName, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + PIN_JAVA_STRING_THREE(file_name, lFileName, cur_name, lCurName, dst_name, lDstName); + if (lFileName != NULL && lCurName != NULL && lDstName != NULL) { + status = H5Lcreate_external(lFileName, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); - UNPIN_JAVA_STRING_THREE(file_name, lFileName, cur_name, lCurName, dst_name, lDstName); + UNPIN_JAVA_STRING_THREE(file_name, lFileName, cur_name, lCurName, dst_name, lDstName); - if (status < 0) - h5libraryError(env); + if (status < 0) + h5libraryError(env); + } } /* end Java_hdf_hdf5lib_H5_H5Lcreate_1external */ /* @@ -101,14 +103,15 @@ Java_hdf_hdf5lib_H5_H5Lcreate_1hard const char *lCurName; const char *lDstName; - PIN_JAVA_STRING_TWO0(cur_name, lCurName, dst_name, lDstName); + PIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + if (lCurName != NULL && lDstName != NULL) { + status = H5Lcreate_hard((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); - status = H5Lcreate_hard((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); - UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); - - if (status < 0) - h5libraryError(env); + if (status < 0) + h5libraryError(env); + } } /* end Java_hdf_hdf5lib_H5_H5Lcreate_1hard */ /* @@ -125,14 +128,15 @@ Java_hdf_hdf5lib_H5_H5Lcreate_1soft const char *lCurName; const char *lDstName; - PIN_JAVA_STRING_TWO0(cur_name, lCurName, dst_name, lDstName); - - status = H5Lcreate_soft(lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + PIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + if (lCurName != NULL && lDstName != NULL) { + status = H5Lcreate_soft(lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); - UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); - if (status < 0) - h5libraryError(env); + if (status < 0) + h5libraryError(env); + } } /* end Java_hdf_hdf5lib_H5_H5Lcreate_1soft */ /* @@ -147,14 +151,15 @@ Java_hdf_hdf5lib_H5_H5Ldelete herr_t status = -1; const char *lName; - PIN_JAVA_STRING0(name, lName); - - status = H5Ldelete((hid_t)loc_id, lName, (hid_t)access_id); + PIN_JAVA_STRING(name, lName); + if (lName != NULL) { + status = H5Ldelete((hid_t)loc_id, lName, (hid_t)access_id); - UNPIN_JAVA_STRING(name, lName); + UNPIN_JAVA_STRING(name, lName); - if (status < 0) - h5libraryError(env); + if (status < 0) + h5libraryError(env); + } } /* end Java_hdf_hdf5lib_H5_H5Ldelete */ /* @@ -171,14 +176,15 @@ Java_hdf_hdf5lib_H5_H5Ldelete_1by_1idx herr_t status; const char *lName; - PIN_JAVA_STRING0(name, lName); - - status = H5Ldelete_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, n, (hid_t)access_id); + PIN_JAVA_STRING(name, lName); + if (lName != NULL) { + status = H5Ldelete_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, n, (hid_t)access_id); - UNPIN_JAVA_STRING(name, lName); + UNPIN_JAVA_STRING(name, lName); - if (status < 0) - h5libraryError(env); + if (status < 0) + h5libraryError(env); + } } /* end Java_hdf_hdf5lib_H5_H5Ldelete_1by_1idx */ /* @@ -193,16 +199,17 @@ Java_hdf_hdf5lib_H5_H5Lexists htri_t bval = JNI_FALSE; const char *lName; - PIN_JAVA_STRING(name, lName, JNI_FALSE); - - bval = H5Lexists((hid_t)loc_id, lName, (hid_t)access_id); + PIN_JAVA_STRING(name, lName); + if (lName != NULL) { + bval = H5Lexists((hid_t)loc_id, lName, (hid_t)access_id); - UNPIN_JAVA_STRING(name, lName); + UNPIN_JAVA_STRING(name, lName); - 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_H5Lexists */ @@ -222,26 +229,27 @@ Java_hdf_hdf5lib_H5_H5Lget_1info H5L_info_t infobuf; const char *lName; - PIN_JAVA_STRING(name, lName, NULL); + PIN_JAVA_STRING(name, lName); + if (lName != NULL) { + status = H5Lget_info((hid_t)loc_id, lName, &infobuf, (hid_t)access_id); - status = H5Lget_info((hid_t)loc_id, lName, &infobuf, (hid_t)access_id); - - UNPIN_JAVA_STRING(name, lName); + UNPIN_JAVA_STRING(name, lName); - if (status < 0) { - h5libraryError(env); + if (status < 0) { + h5libraryError(env); + } /* end if */ + else { + args[0].i = infobuf.type; + args[1].z = infobuf.corder_valid; + args[2].j = infobuf.corder; + args[3].i = infobuf.cset; + if(infobuf.type==0) + args[4].j = (jlong)infobuf.u.address; + else + args[4].j = (jlong)infobuf.u.val_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args); + } /* end else */ } /* end if */ - else { - args[0].i = infobuf.type; - args[1].z = infobuf.corder_valid; - args[2].j = infobuf.corder; - args[3].i = infobuf.cset; - if(infobuf.type==0) - args[4].j = (jlong)infobuf.u.address; - else - args[4].j = (jlong)infobuf.u.val_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args); - } /* end else */ return ret_obj; } /* end Java_hdf_hdf5lib_H5_H5Lget_1info */ @@ -261,26 +269,27 @@ Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx H5L_info_t infobuf; const char *lName; - PIN_JAVA_STRING(name, lName, NULL); + PIN_JAVA_STRING(name, lName); + if (lName != NULL) { + status = H5Lget_info_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id); - status = H5Lget_info_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id); - - UNPIN_JAVA_STRING(name, lName); + UNPIN_JAVA_STRING(name, lName); - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - args[0].i = infobuf.type; - args[1].z = infobuf.corder_valid; - args[2].j = infobuf.corder; - args[3].i = infobuf.cset; - if(infobuf.type==0) - args[4].j = (jlong)infobuf.u.address; - else - args[4].j = (jlong)infobuf.u.val_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args); - } /* end els */ + if (status < 0) { + h5libraryError(env); + } /* end if */ + else { + args[0].i = infobuf.type; + args[1].z = infobuf.corder_valid; + args[2].j = infobuf.corder; + args[3].i = infobuf.cset; + if(infobuf.type==0) + args[4].j = (jlong)infobuf.u.address; + else + args[4].j = (jlong)infobuf.u.val_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args); + } /* end els */ + } return ret_obj; } /* end Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx */ @@ -289,7 +298,7 @@ Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx * Method: H5Lget_name_by_idx * Signature: (JLjava/lang/String;IIJJ)Ljava/lang/String; */ -JNIEXPORT jobject JNICALL +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, jlong link_n, jlong access_id) @@ -300,39 +309,38 @@ Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx const char *lName; char *lValue; - PIN_JAVA_STRING(name, lName, NULL); - - /* get the length of the link name */ - status_size = H5Lget_name_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char*)NULL, (size_t)0, H5P_DEFAULT); - if(status_size < 0) { - UNPIN_JAVA_STRING(name, lName); - h5libraryError(env); - } /* end if */ - else { - buf_size = (size_t)status_size + 1;/* add extra space for the null terminator */ - - lValue = (char*)HDmalloc(sizeof(char) * buf_size); - if (lValue == NULL) { - UNPIN_JAVA_STRING(name, lName); - h5outOfMemory(env, "H5Lget_name_by_idx: malloc failed "); + PIN_JAVA_STRING(name, lName); + if (lName != NULL) { + /* get the length of the link name */ + status_size = H5Lget_name_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char*)NULL, (size_t)0, H5P_DEFAULT); + if(status_size < 0) { + h5libraryError(env); } /* end if */ else { - status_size = H5Lget_name_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char*)lValue, (size_t)buf_size, (hid_t)access_id); + buf_size = (size_t)status_size + 1;/* add extra space for the null terminator */ - UNPIN_JAVA_STRING(name, lName); - - if (status_size < 0) { - HDfree(lValue); - h5libraryError(env); + lValue = (char*)HDmalloc(sizeof(char) * buf_size); + if (lValue == NULL) { + h5outOfMemory(env, "H5Lget_name_by_idx: malloc failed "); } /* end if */ else { - str = ENVPTR->NewStringUTF(ENVPAR lValue); - HDfree(lValue); - if (str == NULL) - h5JNIFatalError(env, "H5Lget_name_by_idx: return string not created"); + status_size = H5Lget_name_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char*)lValue, (size_t)buf_size, (hid_t)access_id); + + if (status_size < 0) { + HDfree(lValue); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR lValue); + HDfree(lValue); + if (str == NULL) + h5JNIFatalError(env, "H5Lget_name_by_idx: return string not created"); + } /* end else */ } /* end else */ } /* end else */ - } /* end else */ + UNPIN_JAVA_STRING(name, lName); + } + return str; } /* end Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx */ @@ -354,79 +362,70 @@ Java_hdf_hdf5lib_H5_H5Lget_1value const char *obj_name; jstring str; - PIN_JAVA_STRING(name, lName, -1); - infobuf.type = -1; - /* get the length of the link val */ - status = H5Lget_info((hid_t)loc_id, lName, &infobuf, H5P_DEFAULT); - if(status < 0) { - UNPIN_JAVA_STRING(name, lName); - h5libraryError(env); - } /* end if */ - else { - buf_size = infobuf.u.val_size + 1;/* add extra space for the null terminator */ - - if(infobuf.type == H5L_TYPE_HARD) { - UNPIN_JAVA_STRING(name, lName); - h5JNIFatalError(env, "H5Lget_val: link is hard type"); + PIN_JAVA_STRING(name, lName); + if (lName != NULL) { + /* get the length of the link val */ + status = H5Lget_info((hid_t)loc_id, lName, &infobuf, H5P_DEFAULT); + if(status < 0) { + h5libraryError(env); } /* end if */ else { - lValue = (char*)HDmalloc(sizeof(char) * buf_size); - if (lValue == NULL) { - UNPIN_JAVA_STRING(name, lName); - h5outOfMemory(env, "H5Lget_val: malloc failed"); + buf_size = infobuf.u.val_size + 1;/* add extra space for the null terminator */ + + if(infobuf.type == H5L_TYPE_HARD) { + h5JNIFatalError(env, "H5Lget_val: link is hard type"); } /* end if */ else { - status = H5Lget_val((hid_t)loc_id, lName, (void*)lValue, buf_size, (hid_t)access_id); - - UNPIN_JAVA_STRING(name, lName); - - if (status < 0) { - HDfree(lValue); - h5libraryError(env); + lValue = (char*)HDmalloc(sizeof(char) * buf_size); + if (lValue == NULL) { + h5outOfMemory(env, "H5Lget_val: malloc failed"); } /* end if */ - else if(infobuf.type == H5L_TYPE_EXTERNAL) { - status = H5Lunpack_elink_val(lValue, (size_t)infobuf.u.val_size, (unsigned*)NULL, &file_name, &obj_name); + else { + status = H5Lget_val((hid_t)loc_id, lName, (void*)lValue, buf_size, (hid_t)access_id); + if (status < 0) { - HDfree(lValue); h5libraryError(env); } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR obj_name); - if (str == NULL) { - HDfree(lValue); - h5JNIFatalError(env, "H5Lget_val: return string not created"); + else if(infobuf.type == H5L_TYPE_EXTERNAL) { + status = H5Lunpack_elink_val(lValue, (size_t)infobuf.u.val_size, (unsigned*)NULL, &file_name, &obj_name); + if (status < 0) { + h5libraryError(env); } /* end if */ else { - ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); - - str = ENVPTR->NewStringUTF(ENVPAR file_name); + str = ENVPTR->NewStringUTF(ENVPAR obj_name); if (str == NULL) { - HDfree(lValue); h5JNIFatalError(env, "H5Lget_val: return string not created"); } /* end if */ else { - ENVPTR->SetObjectArrayElement(ENVPAR link_value, 1, str); - HDfree(lValue); + ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); + + str = ENVPTR->NewStringUTF(ENVPAR file_name); + if (str == NULL) { + h5JNIFatalError(env, "H5Lget_val: return string not created"); + } /* end if */ + else { + ENVPTR->SetObjectArrayElement(ENVPAR link_value, 1, str); + } /* end else */ } /* end else */ } /* end else */ - } /* end else */ - } /* end else if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR lValue); - if (str == NULL) { - /* exception -- fatal JNI error */ - HDfree(lValue); - h5JNIFatalError(env, "H5Lget_val: return string not created"); - } /* end if */ + } /* end else if */ else { - ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); - HDfree(lValue); + str = ENVPTR->NewStringUTF(ENVPAR lValue); + if (str == NULL) { + /* exception -- fatal JNI error */ + h5JNIFatalError(env, "H5Lget_val: return string not created"); + } /* end if */ + else { + ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); + } /* end else */ } /* end else */ + HDfree(lValue); } /* end else */ } /* end else */ } /* end else */ - } /* end else */ + UNPIN_JAVA_STRING(name, lName); + } return infobuf.type; } /* end Java_hdf_hdf5lib_H5_H5Lget_1val */ @@ -450,80 +449,69 @@ Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx const char *obj_name; jstring str; - PIN_JAVA_STRING(name, lName, -1); - infobuf.type = -1; - /* get the length of the link valuee */ - status = H5Lget_info_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id); - if(status < 0) { - UNPIN_JAVA_STRING(name, lName); - h5libraryError(env); - return -1; - } /* end if */ - else { - buf_size = infobuf.u.val_size; - if(buf_size < 0) { - UNPIN_JAVA_STRING(name, lName); + PIN_JAVA_STRING(name, lName); + if (lName != NULL) { + /* get the length of the link valuee */ + status = H5Lget_info_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id); + if(status < 0) { h5libraryError(env); - return -1; } /* end if */ else { - lValue = (void*)HDmalloc(buf_size); - if (lValue == NULL) { - UNPIN_JAVA_STRING(name, lName); - h5outOfMemory(env, "H5Lget_val_by_idx: malloc failed "); - return -1; + buf_size = infobuf.u.val_size; + if(buf_size < 0) { + h5libraryError(env); } /* end if */ else { - status = H5Lget_val_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (void*)lValue, (size_t)buf_size, (hid_t)access_id); - - UNPIN_JAVA_STRING(name, lName); - - if (status < 0) { - HDfree(lValue); - h5libraryError(env); + lValue = (void*)HDmalloc(buf_size); + if (lValue == NULL) { + h5outOfMemory(env, "H5Lget_val_by_idx: malloc failed "); } /* end if */ - else if(infobuf.type == H5L_TYPE_EXTERNAL) { - status = H5Lunpack_elink_val((char*)lValue, (size_t)infobuf.u.val_size, (unsigned*)NULL, (const char**)&file_name, (const char**)&obj_name); + else { + status = H5Lget_val_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (void*)lValue, (size_t)buf_size, (hid_t)access_id); + if (status < 0) { - HDfree(lValue); h5libraryError(env); } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR obj_name); - if (str == NULL) { - HDfree(lValue); - h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); + else if(infobuf.type == H5L_TYPE_EXTERNAL) { + status = H5Lunpack_elink_val((char*)lValue, (size_t)infobuf.u.val_size, (unsigned*)NULL, (const char**)&file_name, (const char**)&obj_name); + if (status < 0) { + h5libraryError(env); } /* end if */ else { - ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); - - str = ENVPTR->NewStringUTF(ENVPAR file_name); + str = ENVPTR->NewStringUTF(ENVPAR obj_name); if (str == NULL) { - HDfree(lValue); h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); } /* end if */ else { - ENVPTR->SetObjectArrayElement(ENVPAR link_value, 1, str); - HDfree(lValue); + ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); + + str = ENVPTR->NewStringUTF(ENVPAR file_name); + if (str == NULL) { + h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); + } /* end if */ + else { + ENVPTR->SetObjectArrayElement(ENVPAR link_value, 1, str); + } /* end else */ } /* end else */ } /* end else */ - } /* end else */ - } /* end else if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR (char *)lValue); - if (str == NULL) { - HDfree(lValue); - h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); - } /* end if */ + } /* end else if */ else { - ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); - HDfree(lValue); + str = ENVPTR->NewStringUTF(ENVPAR (char *)lValue); + if (str == NULL) { + h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); + } /* end if */ + else { + ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); + } /* end else */ } /* end else */ + HDfree(lValue); } /* end else */ } /* end else */ } /* end else */ - } /* end else */ + UNPIN_JAVA_STRING(name, lName); + } + return infobuf.type; } /* end Java_hdf_hdf5lib_H5_H5Lget_1val_1by_1idx */ @@ -541,20 +529,21 @@ Java_hdf_hdf5lib_H5_H5Lmove const char *lCurName; const char *lDstName; - PIN_JAVA_STRING_TWO0(cur_name, lCurName, dst_name, lDstName); + PIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + if (lCurName != NULL && lDstName != NULL) { + status = H5Lmove((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); - status = H5Lmove((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); - UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); - - if (status < 0) - h5libraryError(env); + if (status < 0) + h5libraryError(env); + } } /* end Java_hdf_hdf5lib_H5_H5Lmove */ static herr_t H5L_iterate_cb - (hid_t g_id, const char *name, const H5L_info_t *info, void *op_data) + (hid_t g_id, const char *name, const H5L_info_t *info, void *op_data) { JNIEnv *cbenv; jint status; @@ -645,14 +634,15 @@ Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name h5nullArgument(env, "H5Lvisit_by_name: op_data or callback_op is NULL"); } /* end if */ else { - PIN_JAVA_STRING(name, lName, -1); - - status = H5Lvisit_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void*)op_data, (hid_t)access_id); + PIN_JAVA_STRING(name, lName); + if (lName != NULL) { + status = H5Lvisit_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void*)op_data, (hid_t)access_id); - UNPIN_JAVA_STRING(name, lName); + UNPIN_JAVA_STRING(name, lName); - if (status < 0) - h5libraryError(env); + if (status < 0) + h5libraryError(env); + } } /* end else */ return status; @@ -708,14 +698,15 @@ Java_hdf_hdf5lib_H5_H5Literate_1by_1name h5nullArgument(env, "H5Literate_by_name: op_data or callback_op is NULL"); } /* end if */ else { - PIN_JAVA_STRING(name, lName, -1); + PIN_JAVA_STRING(name, lName); + if (lName != NULL) { + status = H5Literate_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void*)op_data, (hid_t)access_id); - status = H5Literate_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void*)op_data, (hid_t)access_id); - - UNPIN_JAVA_STRING(name, lName); + UNPIN_JAVA_STRING(name, lName); - if (status < 0) - h5libraryError(env); + if (status < 0) + h5libraryError(env); + } } /* end else */ return status; |