summaryrefslogtreecommitdiffstats
path: root/java/src/jni/h5oImp.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2018-08-17 19:25:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2018-08-17 19:25:10 (GMT)
commit105a05cb9072d21b4158eb9743990b07623097a7 (patch)
treec99477d3a019c46d90b3865ec650051ca86786fd /java/src/jni/h5oImp.c
parenta7a814fa83f74981e04cdc2a371e4fd5f26de471 (diff)
parenta6100a3445921480a9d65dbfc49e7600e7923bd5 (diff)
downloadhdf5-105a05cb9072d21b4158eb9743990b07623097a7.zip
hdf5-105a05cb9072d21b4158eb9743990b07623097a7.tar.gz
hdf5-105a05cb9072d21b4158eb9743990b07623097a7.tar.bz2
Merge pull request #1205 in HDFFV/hdf5 from ~BYRN/hdf5_merge_adb:develop to develop
* commit 'a6100a3445921480a9d65dbfc49e7600e7923bd5': HDFFV-10536 callback crash fixed by using stack structure
Diffstat (limited to 'java/src/jni/h5oImp.c')
-rw-r--r--java/src/jni/h5oImp.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/java/src/jni/h5oImp.c b/java/src/jni/h5oImp.c
index 6093e46..1de505a 100644
--- a/java/src/jni/h5oImp.c
+++ b/java/src/jni/h5oImp.c
@@ -27,13 +27,17 @@ extern "C" {
#include "h5oImp.h"
extern JavaVM *jvm;
-extern jobject visit_callback;
+
+typedef struct _cb_wrapper {
+ jobject visit_callback;
+ jobject op_data;
+} cb_wrapper;
/********************/
/* Local Prototypes */
/********************/
-static herr_t H5O_iterate_cb(hid_t g_id, const char *name, const H5O_info_t *info, void *op_data);
+static herr_t H5O_iterate_cb(hid_t g_id, const char *name, const H5O_info_t *info, void *cb_data);
/*
* Class: hdf_hdf5lib_H5
@@ -330,7 +334,7 @@ Java_hdf_hdf5lib_H5_H5Olink
static herr_t
H5O_iterate_cb
- (hid_t g_id, const char *name, const H5O_info_t *info, void *op_data)
+ (hid_t g_id, const char *name, const H5O_info_t *info, void *cb_data)
{
JNIEnv *cbenv;
jint status = -1;
@@ -343,6 +347,9 @@ H5O_iterate_cb
jobject ihinfobuf1;
jobject ihinfobuf2;
jobject cb_info_t = NULL;
+ 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) {
/* printf("JNI H5O_iterate_cb error: AttachCurrentThread failed\n"); */
@@ -448,9 +455,9 @@ Java_hdf_hdf5lib_H5_H5Ovisit
jobject callback_op, jobject op_data, jint fields)
{
herr_t status = -1;
+ cb_wrapper wrapper = {callback_op, op_data};
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
if (op_data == NULL) {
h5nullArgument(env, "H5Ovisit: op_data is NULL");
@@ -459,7 +466,7 @@ Java_hdf_hdf5lib_H5_H5Ovisit
h5nullArgument(env, "H5Ovisit: callback_op is NULL");
} /* end if */
else {
- status = H5Ovisit2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)op_data, (unsigned)fields);
+ status = H5Ovisit2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)&wrapper, (unsigned)fields);
if (status < 0)
h5libraryError(env);
@@ -480,9 +487,9 @@ Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name
{
herr_t status = -1;
const char *lName;
+ cb_wrapper wrapper = {callback_op, op_data};
ENVPTR->GetJavaVM(ENVPAR &jvm);
- visit_callback = callback_op;
if (op_data == NULL) {
h5nullArgument(env, "H5Ovisit_by_name: op_data is NULL");
@@ -495,7 +502,7 @@ Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name
else {
PIN_JAVA_STRING(name, lName);
if (lName != NULL) {
- status = H5Ovisit_by_name2((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)op_data, (unsigned)fields, (hid_t)access_id);
+ status = H5Ovisit_by_name2((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)&wrapper, (unsigned)fields, (hid_t)access_id);
UNPIN_JAVA_STRING(name, lName);