summaryrefslogtreecommitdiffstats
path: root/java/src/jni/h5aImp.c
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/jni/h5aImp.c')
-rw-r--r--java/src/jni/h5aImp.c331
1 files changed, 175 insertions, 156 deletions
diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c
index 5af60fb..5af8aae 100644
--- a/java/src/jni/h5aImp.c
+++ b/java/src/jni/h5aImp.c
@@ -67,14 +67,15 @@ Java_hdf_hdf5lib_H5__1H5Acreate
hid_t attr_id = -1;
const char *aName;
- PIN_JAVA_STRING(name, aName, -1);
+ PIN_JAVA_STRING(name, aName);
+ if (aName != NULL) {
+ attr_id = H5Acreate2((hid_t)loc_id, aName, (hid_t)type_id, (hid_t)space_id, (hid_t)create_plist, (hid_t)H5P_DEFAULT);
- attr_id = H5Acreate2((hid_t)loc_id, aName, (hid_t)type_id, (hid_t)space_id, (hid_t)create_plist, (hid_t)H5P_DEFAULT);
+ UNPIN_JAVA_STRING(name, aName);
- UNPIN_JAVA_STRING(name, aName);
-
- if (attr_id < 0)
- h5libraryError(env);
+ if (attr_id < 0)
+ h5libraryError(env);
+ }
return (jlong)attr_id;
} /* end Java_hdf_hdf5lib_H5__1H5Acreate */
@@ -91,14 +92,15 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1name
hid_t attr_id = -1;
const char *aName;
- PIN_JAVA_STRING(name, aName, -1);
+ PIN_JAVA_STRING(name, aName);
+ if (aName != NULL) {
+ attr_id = H5Aopen_name((hid_t)loc_id, aName);
- attr_id = H5Aopen_name((hid_t)loc_id, aName);
+ UNPIN_JAVA_STRING(name,aName);
- UNPIN_JAVA_STRING(name,aName);
-
- if (attr_id < 0)
- h5libraryError(env);
+ if (attr_id < 0)
+ h5libraryError(env);
+ }
return (jlong)attr_id;
} /* end Java_hdf_hdf5lib_H5__1H5Aopen_1name */
@@ -242,8 +244,7 @@ Java_hdf_hdf5lib_H5_H5Aget_1name
ssize_t buf_size;
/* get the length of the name */
- buf_size = H5Aget_name((hid_t)attr_id, NULL, 0);
-
+ buf_size = H5Aget_name((hid_t)attr_id, 0, NULL);
if (buf_size <= 0) {
h5badArgument(env, "H5Aget_name: buf_size <= 0");
} /* end if */
@@ -299,14 +300,15 @@ Java_hdf_hdf5lib_H5_H5Adelete
herr_t status = -1;
const char *aName;
- PIN_JAVA_STRING(name, aName, -1);
-
- status = H5Adelete((hid_t)loc_id, aName);
+ PIN_JAVA_STRING(name, aName);
+ if (aName != NULL) {
+ status = H5Adelete((hid_t)loc_id, aName);
- UNPIN_JAVA_STRING(name, aName);
+ UNPIN_JAVA_STRING(name, aName);
- if (status < 0)
- h5libraryError(env);
+ if (status < 0)
+ h5libraryError(env);
+ }
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Adelete */
@@ -344,15 +346,16 @@ Java_hdf_hdf5lib_H5__1H5Acreate2
hid_t status = -1;
const char *aName;
- PIN_JAVA_STRING(name, aName, -1);
+ PIN_JAVA_STRING(name, aName);
+ if (aName != NULL) {
+ status = H5Acreate2((hid_t)loc_id, aName, (hid_t)type_id,
+ (hid_t)space_id, (hid_t)create_plist, (hid_t)access_plist );
- status = H5Acreate2((hid_t)loc_id, aName, (hid_t)type_id,
- (hid_t)space_id, (hid_t)create_plist, (hid_t)access_plist );
+ UNPIN_JAVA_STRING(name, aName);
- UNPIN_JAVA_STRING(name, aName);
-
- if (status < 0)
- h5libraryError(env);
+ if (status < 0)
+ h5libraryError(env);
+ }
return (jlong)status;
} /* end Java_hdf_hdf5lib_H5__1H5Acreate2 */
@@ -371,14 +374,15 @@ Java_hdf_hdf5lib_H5__1H5Aopen
hid_t retVal = -1;
const char *aName;
- PIN_JAVA_STRING(name, aName, -1);
+ PIN_JAVA_STRING(name, aName);
+ if (aName != NULL) {
+ retVal = H5Aopen((hid_t)obj_id, aName, (hid_t)access_plist);
- retVal = H5Aopen((hid_t)obj_id, aName, (hid_t)access_plist);
+ UNPIN_JAVA_STRING(name, aName);
- UNPIN_JAVA_STRING(name, aName);
-
- if (retVal < 0)
- h5libraryError(env);
+ if (retVal < 0)
+ h5libraryError(env);
+ }
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5__1H5Aopen */
@@ -395,15 +399,16 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx
hid_t retVal = -1;
const char *aName;
- PIN_JAVA_STRING(name, aName, -1);
-
- retVal = H5Aopen_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type,
- (H5_iter_order_t)order, (hsize_t)n, (hid_t)aapl_id, (hid_t)lapl_id);
+ PIN_JAVA_STRING(name, aName);
+ if (aName != NULL) {
+ retVal = H5Aopen_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type,
+ (H5_iter_order_t)order, (hsize_t)n, (hid_t)aapl_id, (hid_t)lapl_id);
- UNPIN_JAVA_STRING(name, aName);
+ UNPIN_JAVA_STRING(name, aName);
- if (retVal < 0)
- h5libraryError(env);
+ if (retVal < 0)
+ h5libraryError(env);
+ }
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx */
@@ -421,15 +426,16 @@ Java_hdf_hdf5lib_H5__1H5Acreate_1by_1name
const char *aName;
const char *attrName;
- PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName, -1);
-
- retVal = H5Acreate_by_name((hid_t)loc_id, aName, attrName, (hid_t)type_id,
- (hid_t)space_id, (hid_t)acpl_id, (hid_t)aapl_id, (hid_t)lapl_id);
+ PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName);
+ if (aName != NULL && attrName != NULL) {
+ retVal = H5Acreate_by_name((hid_t)loc_id, aName, attrName, (hid_t)type_id,
+ (hid_t)space_id, (hid_t)acpl_id, (hid_t)aapl_id, (hid_t)lapl_id);
- UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName);
+ UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName);
- if (retVal < 0)
- h5libraryError(env);
+ if (retVal < 0)
+ h5libraryError(env);
+ }
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5__1H5Acreate_1by_1name */
@@ -443,20 +449,23 @@ JNIEXPORT jboolean JNICALL
Java_hdf_hdf5lib_H5_H5Aexists_1by_1name
(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong lapl_id)
{
- htri_t retVal = -1;
+ htri_t bval = JNI_FALSE;
const char *aName;
const char *attrName;
- PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName, JNI_FALSE);
-
- retVal = H5Aexists_by_name((hid_t)loc_id, aName, attrName, (hid_t)lapl_id);
+ PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName);
+ if (aName != NULL && attrName != NULL) {
+ bval = H5Aexists_by_name((hid_t)loc_id, aName, attrName, (hid_t)lapl_id);
- UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName);
+ UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName);
- if (retVal < 0)
- h5libraryError(env);
+ if (bval > 0)
+ bval = JNI_TRUE;
+ else if (bval < 0)
+ h5libraryError(env);
+ }
- return (jboolean)retVal;
+ return (jboolean)bval;
} /* end Java_hdf_hdf5lib_H5_H5Aexists_1by_1name */
/*
@@ -472,14 +481,15 @@ Java_hdf_hdf5lib_H5_H5Arename
const char *oName;
const char *nName;
- PIN_JAVA_STRING_TWO(old_attr_name, oName, new_attr_name, nName, -1);
-
- retVal = H5Arename((hid_t)loc_id, oName, nName);
+ PIN_JAVA_STRING_TWO(old_attr_name, oName, new_attr_name, nName);
+ if (oName != NULL && nName != NULL) {
+ retVal = H5Arename((hid_t)loc_id, oName, nName);
- UNPIN_JAVA_STRING_TWO(old_attr_name, oName, new_attr_name, nName);
+ UNPIN_JAVA_STRING_TWO(old_attr_name, oName, new_attr_name, nName);
- if (retVal < 0)
- h5libraryError(env);
+ if (retVal < 0)
+ h5libraryError(env);
+ }
return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Arename */
@@ -499,14 +509,15 @@ Java_hdf_hdf5lib_H5_H5Arename_1by_1name
const char *oName;
const char *nName;
- PIN_JAVA_STRING_THREE(obj_name, aName, old_attr_name, oName, new_attr_name, nName, -1);
-
- retVal = H5Arename_by_name((hid_t)loc_id, aName, oName, nName, (hid_t)lapl_id);
+ PIN_JAVA_STRING_THREE(obj_name, aName, old_attr_name, oName, new_attr_name, nName);
+ if (aName != NULL && oName != NULL && nName != NULL) {
+ retVal = H5Arename_by_name((hid_t)loc_id, aName, oName, nName, (hid_t)lapl_id);
- UNPIN_JAVA_STRING_THREE(obj_name, aName, old_attr_name, oName, new_attr_name, nName);
+ UNPIN_JAVA_STRING_THREE(obj_name, aName, old_attr_name, oName, new_attr_name, nName);
- if (retVal < 0)
- h5libraryError(env);
+ if (retVal < 0)
+ h5libraryError(env);
+ }
return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Arename_1by_1name */
@@ -526,44 +537,45 @@ Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx
jstring str = NULL;
const char *aName;
- PIN_JAVA_STRING(obj_name, aName, NULL);
+ PIN_JAVA_STRING(obj_name, aName);
+ if (aName != NULL) {
+ /* get the length of the attribute name */
+ status_size = H5Aget_name_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type,
+ (H5_iter_order_t) order, (hsize_t) n, (char*)NULL, (size_t)0, (hid_t)lapl_id);
- /* get the length of the attribute name */
- status_size = H5Aget_name_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type,
- (H5_iter_order_t) order, (hsize_t) n, (char*)NULL, (size_t)0, (hid_t)lapl_id);
-
- if(status_size < 0) {
- UNPIN_JAVA_STRING(obj_name, aName);
- h5libraryError(env);
- } /* end if */
- else {
- buf_size = (size_t)status_size + 1;/* add extra space for the null terminator */
-
- aValue = (char*)HDmalloc(sizeof(char) * buf_size);
- if (aValue == NULL) {
+ if(status_size < 0) {
UNPIN_JAVA_STRING(obj_name, aName);
- h5outOfMemory(env, "H5Aget_name_by_idx: malloc failed ");
+ h5libraryError(env);
} /* end if */
else {
- status_size = H5Aget_name_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type,
- (H5_iter_order_t) order, (hsize_t) n, (char*)aValue, (size_t)buf_size, (hid_t)lapl_id);
-
- UNPIN_JAVA_STRING(obj_name, aName);
+ buf_size = (size_t)status_size + 1;/* add extra space for the null terminator */
- if (status_size < 0) {
- HDfree(aValue);
- h5libraryError(env);
+ aValue = (char*)HDmalloc(sizeof(char) * buf_size);
+ if (aValue == NULL) {
+ UNPIN_JAVA_STRING(obj_name, aName);
+ h5outOfMemory(env, "H5Aget_name_by_idx: malloc failed ");
} /* end if */
else {
- str = ENVPTR->NewStringUTF(ENVPAR aValue);
- HDfree(aValue);
- if (str == NULL) {
- /* exception -- fatal JNI error */
- h5JNIFatalError(env, "H5Aget_name_by_idx: return string not created");
+ status_size = H5Aget_name_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type,
+ (H5_iter_order_t) order, (hsize_t) n, (char*)aValue, (size_t)buf_size, (hid_t)lapl_id);
+
+ UNPIN_JAVA_STRING(obj_name, aName);
+
+ if (status_size < 0) {
+ HDfree(aValue);
+ h5libraryError(env);
} /* end if */
+ else {
+ str = ENVPTR->NewStringUTF(ENVPAR aValue);
+ HDfree(aValue);
+ if (str == NULL) {
+ /* exception -- fatal JNI error */
+ h5JNIFatalError(env, "H5Aget_name_by_idx: return string not created");
+ } /* end if */
+ } /* end else */
} /* end else */
} /* end else */
- } /* end else */
+ }
return str;
} /* end Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx */
@@ -628,23 +640,24 @@ Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx
jobject ret_obj = NULL;
const char *aName;
- PIN_JAVA_STRING(obj_name, aName, NULL);
+ PIN_JAVA_STRING(obj_name, aName);
+ if (aName != NULL) {
+ status = H5Aget_info_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type,
+ (H5_iter_order_t)order, (hsize_t)n, &ainfo, (hid_t)lapl_id);
- status = H5Aget_info_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type,
- (H5_iter_order_t)order, (hsize_t)n, &ainfo, (hid_t)lapl_id);
-
- UNPIN_JAVA_STRING(obj_name, aName);
+ UNPIN_JAVA_STRING(obj_name, aName);
- if (status < 0) {
- h5libraryError(env);
- } /* end if */
- else {
- args[0].z = ainfo.corder_valid;
- args[1].j = ainfo.corder;
- args[2].i = ainfo.cset;
- args[3].j = (jlong)ainfo.data_size;
- CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args);
- } /* end else */
+ if (status < 0) {
+ h5libraryError(env);
+ } /* end if */
+ else {
+ args[0].z = ainfo.corder_valid;
+ args[1].j = ainfo.corder;
+ args[2].i = ainfo.cset;
+ args[3].j = (jlong)ainfo.data_size;
+ CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args);
+ } /* end else */
+ }
return ret_obj;
} /* end Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx */
@@ -664,22 +677,23 @@ Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1name
jvalue args[4];
jobject ret_obj = NULL;
- PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName, NULL);
+ PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName);
+ if (aName != NULL && attrName != NULL) {
+ status = H5Aget_info_by_name((hid_t)loc_id, aName, attrName, &ainfo, (hid_t)lapl_id);
- status = H5Aget_info_by_name((hid_t)loc_id, aName, attrName, &ainfo, (hid_t)lapl_id);
+ UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName);
- UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName);
-
- if (status < 0) {
- h5libraryError(env);
- } /* end if */
- else {
- args[0].z = ainfo.corder_valid;
- args[1].j = ainfo.corder;
- args[2].i = ainfo.cset;
- args[3].j = (jlong)ainfo.data_size;
- CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args);
- } /* end else */
+ if (status < 0) {
+ h5libraryError(env);
+ } /* end if */
+ else {
+ args[0].z = ainfo.corder_valid;
+ args[1].j = ainfo.corder;
+ args[2].i = ainfo.cset;
+ args[3].j = (jlong)ainfo.data_size;
+ CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args);
+ } /* end else */
+ }
return ret_obj;
} /* end Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1name */
@@ -696,14 +710,15 @@ Java_hdf_hdf5lib_H5_H5Adelete_1by_1name
const char *aName;
const char *attrName;
- PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName, -1);
-
- retVal = H5Adelete_by_name((hid_t)loc_id, aName, attrName, (hid_t)lapl_id);
+ PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName);
+ if (aName != NULL && attrName != NULL) {
+ retVal = H5Adelete_by_name((hid_t)loc_id, aName, attrName, (hid_t)lapl_id);
- UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName);
+ UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName);
- if (retVal < 0)
- h5libraryError(env);
+ if (retVal < 0)
+ h5libraryError(env);
+ }
return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Adelete_1by_1name */
@@ -720,16 +735,17 @@ Java_hdf_hdf5lib_H5_H5Aexists
htri_t bval = JNI_FALSE;
const char *aName;
- PIN_JAVA_STRING(attr_name, aName, JNI_FALSE);
+ PIN_JAVA_STRING(attr_name, aName);
+ if (aName != NULL) {
+ bval = H5Aexists((hid_t)obj_id, aName);
- bval = H5Aexists((hid_t)obj_id, aName);
+ UNPIN_JAVA_STRING(attr_name, aName);
- UNPIN_JAVA_STRING(attr_name, aName);
-
- 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_H5Aexists */
@@ -746,14 +762,15 @@ Java_hdf_hdf5lib_H5_H5Adelete_1by_1idx
herr_t status = -1;
const char *aName;
- PIN_JAVA_STRING0(obj_name, aName);
-
- status = H5Adelete_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t)n, (hid_t)lapl_id);
+ PIN_JAVA_STRING(obj_name, aName);
+ if (aName != NULL) {
+ status = H5Adelete_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t)n, (hid_t)lapl_id);
- UNPIN_JAVA_STRING(obj_name, aName);
+ UNPIN_JAVA_STRING(obj_name, aName);
- if (status < 0)
- h5libraryError(env);
+ if (status < 0)
+ h5libraryError(env);
+ }
} /* end Java_hdf_hdf5lib_H5_H5Adelete_1by_1idx */
/*
@@ -770,14 +787,15 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1by_1name
const char *aName;
const char *oName;
- PIN_JAVA_STRING_TWO(obj_name, oName, attr_name, aName, -1);
-
- status = H5Aopen_by_name((hid_t)loc_id, oName, aName, (hid_t)aapl_id, (hid_t)lapl_id);
+ PIN_JAVA_STRING_TWO(obj_name, oName, attr_name, aName);
+ if (oName != NULL && aName != NULL) {
+ status = H5Aopen_by_name((hid_t)loc_id, oName, aName, (hid_t)aapl_id, (hid_t)lapl_id);
- UNPIN_JAVA_STRING_TWO(obj_name, oName, attr_name, aName);
+ UNPIN_JAVA_STRING_TWO(obj_name, oName, attr_name, aName);
- if (status < 0)
- h5libraryError(env);
+ if (status < 0)
+ h5libraryError(env);
+ }
return (jlong)status;
} /* end Java_hdf_hdf5lib_H5__1H5Aopen_1by_1name */
@@ -892,14 +910,15 @@ Java_hdf_hdf5lib_H5_H5Aiterate_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 = H5Aiterate_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void*)op_data, (hid_t)access_id);
- status = H5Aiterate_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_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 (jint)status;