diff options
Diffstat (limited to 'java/src/jni/h5dImp.c')
-rw-r--r-- | java/src/jni/h5dImp.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c index 205e9fb..652c873 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 @@ -1105,7 +1109,7 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1string const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); if (utf8) { - strncpy(&c_buf[i * str_len], utf8, str_len); + HDstrncpy(&c_buf[i * str_len], utf8, str_len); } /* end if */ ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); @@ -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); |