diff options
author | Allen Byrne <50328838+byrnHDF@users.noreply.github.com> | 2022-12-06 04:29:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-06 04:29:42 (GMT) |
commit | 2376723d4a8999e5969c862a3ba8619951126cad (patch) | |
tree | 6f63238c5d47b4c6ea6900887cad432b8361e632 /java/src/jni/h5aImp.c | |
parent | 281984b3e3c0ca7ad92055852534577da34777e8 (diff) | |
download | hdf5-2376723d4a8999e5969c862a3ba8619951126cad.zip hdf5-2376723d4a8999e5969c862a3ba8619951126cad.tar.gz hdf5-2376723d4a8999e5969c862a3ba8619951126cad.tar.bz2 |
Develop jni trans (#2266)
* Add compound and refactor out atomic types
* Add Array String tests back
* Convert Attribute version of compound example
* Update transfer atom8ic read to return object
Diffstat (limited to 'java/src/jni/h5aImp.c')
-rw-r--r-- | java/src/jni/h5aImp.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c index 71caf76..07ecdb8 100644 --- a/java/src/jni/h5aImp.c +++ b/java/src/jni/h5aImp.c @@ -1115,7 +1115,8 @@ Java_hdf_hdf5lib_H5_H5AreadVL(JNIEnv *env, jclass clss, jlong attr_id, jlong mem H5T_class_t type_class; jsize vl_array_len; htri_t vl_data_class; - herr_t status = FAIL; + herr_t status = FAIL; + htri_t is_variable = 0; UNUSED(clss); @@ -1124,10 +1125,11 @@ Java_hdf_hdf5lib_H5_H5AreadVL(JNIEnv *env, jclass clss, jlong attr_id, jlong mem if ((vl_data_class = h5str_detect_vlen(mem_type_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); - /* Get size of data array */ if ((vl_array_len = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread: readBuf length < 0"); + if ((is_variable = H5Tis_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); if (!(typeSize = H5Tget_size(mem_type_id))) H5_LIBRARY_ERROR(ENVONLY); @@ -1154,7 +1156,10 @@ done: if (sid >= 0) H5Sclose(sid); } - + if (is_variable) { + for (size_t i = 0; i < (size_t)vl_array_len; i++) + HDfree(((char **)readBuf)[i]); + } HDfree(readBuf); } @@ -1177,7 +1182,8 @@ Java_hdf_hdf5lib_H5_H5AwriteVL(JNIEnv *env, jclass clss, jlong attr_id, jlong me H5T_class_t type_class; jsize vl_array_len; htri_t vl_data_class; - herr_t status = FAIL; + herr_t status = FAIL; + htri_t is_variable = 0; UNUSED(clss); @@ -1192,6 +1198,8 @@ Java_hdf_hdf5lib_H5_H5AwriteVL(JNIEnv *env, jclass clss, jlong attr_id, jlong me CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite: write buffer length < 0"); } + if ((is_variable = H5Tis_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); if (!(typeSize = H5Tget_size(mem_type_id))) H5_LIBRARY_ERROR(ENVONLY); @@ -1216,6 +1224,10 @@ done: H5Treclaim(attr_id, sid, H5P_DEFAULT, writeBuf); } + if (is_variable) { + for (size_t i = 0; i < (size_t)vl_array_len; i++) + HDfree(((char **)writeBuf)[i]); + } HDfree(writeBuf); } |