diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2018-08-21 13:23:12 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2018-08-21 13:23:12 (GMT) |
commit | 3537a81e35b64903bcafd92a411cd1ca02ce4f2b (patch) | |
tree | d6e7d13a89ce996f540f9b804046e38e2c0a63ee /java/src/jni/h5dImp.c | |
parent | c9b8f6b44b0fb803047f5445e15c4137d7a4e630 (diff) | |
download | hdf5-3537a81e35b64903bcafd92a411cd1ca02ce4f2b.zip hdf5-3537a81e35b64903bcafd92a411cd1ca02ce4f2b.tar.gz hdf5-3537a81e35b64903bcafd92a411cd1ca02ce4f2b.tar.bz2 |
HDFFV-10536 Convert iterator callbacks from global to stack var
Diffstat (limited to 'java/src/jni/h5dImp.c')
-rw-r--r-- | java/src/jni/h5dImp.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c index 205e9fb..f984948 100644 --- a/java/src/jni/h5dImp.c +++ b/java/src/jni/h5dImp.c @@ -30,7 +30,11 @@ extern "C" { #include "h5dImp.h" extern JavaVM *jvm; -extern jobject visit_callback; + +typedef struct _cb_wrapper { + jobject visit_callback; + jobject op_data; +} cb_wrapper; #ifdef __cplusplus #ifdef _WINDOWS @@ -1362,13 +1366,9 @@ Java_hdf_hdf5lib_H5_H5DwriteVL isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */ } if (isStr == 0 || isComplex>0 || isVlenStr) { - h5unimplemented(env, "H5DwriteVL: VL types, which are not string type, not implemented"); - status = -1; -#ifdef notdef status = H5DwriteVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf); -#endif } else if (isStr > 0) { status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, @@ -1892,7 +1892,7 @@ Java_hdf_hdf5lib_H5_H5Dset_1extent static herr_t H5D_iterate_cb - (void* elem, hid_t elem_id, unsigned ndim, const hsize_t *point, void *op_data) { + (void* elem, hid_t elem_id, unsigned ndim, const hsize_t *point, void *cb_data) { JNIEnv *cbenv; jint status; jclass cls; @@ -1900,6 +1900,9 @@ H5D_iterate_cb jbyteArray elemArray; jlongArray pointArray; jsize size; + cb_wrapper *wrapper = (cb_wrapper *)cb_data; + void *op_data = (void *)wrapper->op_data; + jobject visit_callback = wrapper->visit_callback; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { JVMPTR->DetachCurrentThread(JVMPAR); @@ -1962,9 +1965,9 @@ Java_hdf_hdf5lib_H5_H5Diterate herr_t status = -1; jboolean isCopy; jbyte *buffP; + cb_wrapper wrapper = {callback_op, op_data}; ENVPTR->GetJavaVM(ENVPAR &jvm); - visit_callback = callback_op; if (op_data == NULL) { h5nullArgument(env, "H5Diterate: op_data is NULL"); @@ -1981,7 +1984,7 @@ Java_hdf_hdf5lib_H5_H5Diterate h5JNIFatalError(env, "H5Diterate: buf not pinned"); } /* end if */ else { - status = H5Diterate((void*)buffP, (hid_t)buf_type, (hid_t)space, (H5D_operator_t)H5D_iterate_cb, (void*)op_data); + status = H5Diterate((void*)buffP, (hid_t)buf_type, (hid_t)space, (H5D_operator_t)H5D_iterate_cb, (void*)&wrapper); if (status < 0) { ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, JNI_ABORT); |