diff options
Diffstat (limited to 'java/src/jni/h5util.c')
-rw-r--r-- | java/src/jni/h5util.c | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index 5e2fe00..385bfc7 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -2002,116 +2002,6 @@ h5tools_dump_simple_data /* * Class: hdf_hdf5lib_H5 - * Method: H5AwriteVL - * Signature: (JJ[Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5AwriteVL - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) -{ - herr_t status = -1; - char **wdata; - jsize size; - jint i; - - size = ENVPTR->GetArrayLength(ENVPAR (jarray) buf); - - wdata = (char**)HDcalloc((size_t)size + 1, sizeof(char*)); - if (!wdata) { - h5JNIFatalError(env, "H5AwriteVL: cannot allocate buffer"); - } /* end if */ - else { - HDmemset(wdata, 0, (size_t)size * sizeof(char*)); - for (i = 0; i < size; ++i) { - jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray) buf, i); - if (obj != 0) { - jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); - const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); - - if (utf8) { - wdata[i] = (char*)HDmalloc((size_t)length + 1); - if (wdata[i]) { - HDmemset(wdata[i], 0, ((size_t)length + 1)); - HDstrncpy(wdata[i], utf8, (size_t)length); - } /* end if */ - } /* end if */ - - ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); - ENVPTR->DeleteLocalRef(ENVPAR obj); - } /* end if */ - } /* end for (i = 0; i < size; ++i) */ - - status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, wdata); - - for (i = 0; i < size; i++) { - if(wdata[i]) { - HDfree(wdata[i]); - } /* end if */ - } /* end for */ - HDfree(wdata); - - if (status < 0) - h5libraryError(env); - } /* end else */ - - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5AwriteVL */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5AreadVL - * Signature: (JJ[Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5AreadVL - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) -{ - herr_t status = -1; - jstring jstr; - char **strs; - int i, n; - hid_t sid; - hsize_t dims[H5S_MAX_RANK]; - - n = ENVPTR->GetArrayLength(ENVPAR buf); - - strs =(char **)HDmalloc((size_t)n * sizeof(char *)); - if (strs == NULL) { - h5JNIFatalError( env, "H5AreadVL: failed to allocate buff for read variable length strings"); - } /* end if */ - else { - status = H5Aread(attr_id, mem_type_id, strs); - if (status < 0) { - dims[0] = (hsize_t)n; - sid = H5Screate_simple(1, dims, NULL); - H5Dvlen_reclaim(mem_type_id, sid, H5P_DEFAULT, strs); - H5Sclose(sid); - HDfree(strs); - h5JNIFatalError(env, "H5AreadVL: failed to read variable length strings"); - } /* end if */ - else { - for (i=0; i<n; i++) { - jstr = ENVPTR->NewStringUTF(ENVPAR strs[i]); - ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); - HDfree (strs[i]); - } /* end for */ - - /* - for repeatedly reading an attribute with a large number of strs (e.g., 1,000,000 strings, - H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect - free space in time. Instead, use "free(strs[i])" to free individual strings - after it is done. - H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, strs); - */ - - HDfree(strs); - } /* end else */ - } /* end else */ - return status; -} /* end Java_hdf_hdf5lib_H5_H5AreadVL */ - -/* - * Class: hdf_hdf5lib_H5 * Method: H5AreadComplex * Signature: (JJ[Ljava/lang/String;)I */ |