summaryrefslogtreecommitdiffstats
path: root/java/src/jni/h5vlImp.c
diff options
context:
space:
mode:
authorM. Scot Breitenfeld <brtnfld@hdfgroup.org>2019-06-25 17:39:35 (GMT)
committerM. Scot Breitenfeld <brtnfld@hdfgroup.org>2019-06-25 17:39:35 (GMT)
commit35c9af8371c4da7f5327c76ddab097b442128f59 (patch)
treed51be51c385a9b463388ba154efc3fa37cad49e8 /java/src/jni/h5vlImp.c
parentc752332bfd0e9c3090f3a0c02d0253cd45c2e2ce (diff)
parent1d8f7bf297100ec11204442708a7f670a89f3f02 (diff)
downloadhdf5-35c9af8371c4da7f5327c76ddab097b442128f59.zip
hdf5-35c9af8371c4da7f5327c76ddab097b442128f59.tar.gz
hdf5-35c9af8371c4da7f5327c76ddab097b442128f59.tar.bz2
Merge branch 'develop' into parallel_vds_developinactive/parallel_vds_develop
Diffstat (limited to 'java/src/jni/h5vlImp.c')
-rw-r--r--java/src/jni/h5vlImp.c157
1 files changed, 86 insertions, 71 deletions
diff --git a/java/src/jni/h5vlImp.c b/java/src/jni/h5vlImp.c
index 89ea703..92e456e 100644
--- a/java/src/jni/h5vlImp.c
+++ b/java/src/jni/h5vlImp.c
@@ -21,9 +21,9 @@
extern "C" {
#endif /* __cplusplus */
-#include "hdf5.h"
#include <jni.h>
#include <stdlib.h>
+#include "hdf5.h"
#include "h5jni.h"
#include "h5vlImp.h"
@@ -36,18 +36,22 @@ JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name
(JNIEnv *env, jclass clss, jobject connector_name, jlong vipl_id)
{
- hid_t status = -1;
- const char *vlName;
+ const char *volName = NULL;
+ hid_t status = H5I_INVALID_HID;
- PIN_JAVA_STRING(connector_name, vlName);
- if (vlName != NULL) {
- status = H5VLregister_connector_by_name(vlName, (hid_t)vipl_id);
+ UNUSED(clss);
- UNPIN_JAVA_STRING(connector_name, vlName);
+ if (NULL == connector_name)
+ H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLregister_connector_by_name: VOL connector name is NULL");
- if (status < 0)
- h5libraryError(env);
- }
+ PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLregister_connector_by_name: VOL connector name not pinned");
+
+ if ((status = H5VLregister_connector_by_name(volName, (hid_t)vipl_id)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+
+done:
+ if (volName)
+ UNPIN_JAVA_STRING(ENVONLY, connector_name, volName);
return (jlong)status;
} /* end Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name */
@@ -61,11 +65,14 @@ JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value
(JNIEnv *env, jclass clss, jint connector_value, jlong vipl_id)
{
- hid_t status = H5VLregister_connector_by_value((H5VL_class_value_t)connector_value, (hid_t)vipl_id);
+ hid_t status = H5I_INVALID_HID;
+
+ UNUSED(clss);
- if (status < 0)
- h5libraryError(env);
+ if ((status = H5VLregister_connector_by_value((H5VL_class_value_t)connector_value, (hid_t)vipl_id)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+done:
return (jlong)status;
} /* end Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value */
@@ -78,20 +85,24 @@ JNIEXPORT jboolean JNICALL
Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered
(JNIEnv *env, jclass clss, jobject connector_name)
{
+ const char *volName = NULL;
htri_t bval = JNI_FALSE;
- const char *vlName;
- PIN_JAVA_STRING(connector_name, vlName);
- if (vlName != NULL) {
- bval = H5VLis_connector_registered(vlName);
+ UNUSED(clss);
- UNPIN_JAVA_STRING(connector_name, vlName);
+ if (NULL == connector_name)
+ H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLis_connector_registered: VOL connector name is NULL");
- if (bval > 0)
- bval = JNI_TRUE;
- else if (bval < 0)
- h5libraryError(env);
- }
+ PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLis_connector_registered: VOL connector name not pinned");
+
+ if ((bval = H5VLis_connector_registered(volName)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+
+ bval = (bval > 0) ? JNI_TRUE : JNI_FALSE;
+
+done:
+ if (volName)
+ UNPIN_JAVA_STRING(ENVONLY, connector_name, volName);
return (jboolean)bval;
} /* end Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered */
@@ -105,18 +116,22 @@ JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5VLget_1connector_1id
(JNIEnv *env, jclass clss, jobject connector_name)
{
- hid_t status = -1;
- const char *vlName;
+ const char *volName = NULL;
+ hid_t status = H5I_INVALID_HID;
- PIN_JAVA_STRING(connector_name, vlName);
- if (vlName != NULL) {
- status = H5VLget_connector_id(vlName);
+ UNUSED(clss);
- UNPIN_JAVA_STRING(connector_name, vlName);
+ if (NULL == connector_name)
+ H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLget_connector_id: VOL connector name is NULL");
- if (status < 0)
- h5libraryError(env);
- }
+ PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLget_connector_id: VOL connector name not pinned");
+
+ if ((status = H5VLget_connector_id(volName)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+
+done:
+ if (volName)
+ UNPIN_JAVA_STRING(ENVONLY, connector_name, volName);
return (jlong)status;
} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1id */
@@ -131,41 +146,31 @@ JNIEXPORT jobject JNICALL
Java_hdf_hdf5lib_H5_H5VLget_1connector_1name
(JNIEnv *env, jclass clss, jlong object_id)
{
- char *vlName;
- ssize_t buf_size;
- ssize_t status;
+ ssize_t buf_size, status;
+ char *volName = NULL;
jstring str = NULL;
- /* get the length of the comment */
- buf_size = H5VLget_connector_name((hid_t)object_id, NULL, 0);
- if (buf_size < 0) {
- H5Eprint2(H5E_DEFAULT, NULL);
-
- h5badArgument(env, "H5VLget_connector_name: buf_size < 0");
- } /* end if */
- else if (buf_size > 0) {
- buf_size++; /* add extra space for the null terminator */
- vlName = (char *)HDmalloc(sizeof(char) * (size_t)buf_size);
- if (vlName == NULL) {
- /* exception -- out of memory */
- h5outOfMemory(env, "H5VLget_connector_name: malloc failed");
- } /* end if */
- else {
- status = H5VLget_connector_name((hid_t)object_id, vlName, (size_t)buf_size);
-
- if (status < 0) {
- h5libraryError(env);
- } /* end if */
- else {
- /* may throw OutOfMemoryError */
- str = ENVPTR->NewStringUTF(ENVPAR vlName);
- if (str == NULL) {
- h5JNIFatalError(env, "H5VLget_connector_name: return string not allocated");
- } /* end if */
- } /* end else */
- HDfree(vlName);
- }
- } /* end else if */
+ UNUSED(clss);
+
+ /* Get the length of the comment */
+ if ((buf_size = H5VLget_connector_name((hid_t)object_id, NULL, 0)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+
+ if (buf_size > 0) {
+ if (NULL == (volName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1)))
+ H5_JNI_FATAL_ERROR(ENVONLY, "H5VLget_connector_name: failed to allocated VOL connector name buffer");
+
+ if ((status = H5VLget_connector_name((hid_t)object_id, volName, (size_t)buf_size + 1)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+ volName[buf_size] = '\0';
+
+ if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, volName)))
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ }
+
+done:
+ if (volName)
+ HDfree(volName);
return (jstring)str;
} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1name */
@@ -179,10 +184,15 @@ JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5VLclose
(JNIEnv *env, jclass clss, jlong connector_id)
{
- herr_t retValue = H5VLclose((hid_t)connector_id);
+ herr_t retValue = FAIL;
+
+ UNUSED(clss);
+
+ if ((retValue = H5VLclose((hid_t)connector_id)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
- if (retValue < 0)
- h5libraryError(env);
+done:
+ return;
} /* end Java_hdf_hdf5lib_H5_H5VLclose */
/*
@@ -194,10 +204,15 @@ JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5VLunregister_1connector
(JNIEnv *env, jclass clss, jlong connector_id)
{
- herr_t retValue = H5VLunregister_connector((hid_t)connector_id);
+ herr_t retValue = FAIL;
+
+ UNUSED(clss);
+
+ if ((retValue = H5VLunregister_connector((hid_t)connector_id)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
- if (retValue < 0)
- h5libraryError(env);
+done:
+ return;
} /* end Java_hdf_hdf5lib_H5_H5VLunregister_1connector */