diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-02-27 22:54:52 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-02-27 22:54:52 (GMT) |
commit | 467b5d565cc6bb0a75f10ac0807c38ee0a0939a9 (patch) | |
tree | c2d87fcc51f380a2306949753c40cebd9e9aa796 /java/src | |
parent | f1aca8780ea647e705760149ceb925e363c31763 (diff) | |
download | hdf5-467b5d565cc6bb0a75f10ac0807c38ee0a0939a9.zip hdf5-467b5d565cc6bb0a75f10ac0807c38ee0a0939a9.tar.gz hdf5-467b5d565cc6bb0a75f10ac0807c38ee0a0939a9.tar.bz2 |
Merge CMake and tools changes from develop
Diffstat (limited to 'java/src')
30 files changed, 568 insertions, 545 deletions
diff --git a/java/src/CMakeLists.txt b/java/src/CMakeLists.txt index 3f80d8f..0bfbaf7 100644 --- a/java/src/CMakeLists.txt +++ b/java/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_JAVA_SRC C) #----------------------------------------------------------------------------- diff --git a/java/src/hdf/CMakeLists.txt b/java/src/hdf/CMakeLists.txt index 161ddf1..5660158 100644 --- a/java/src/hdf/CMakeLists.txt +++ b/java/src/hdf/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_JAVA_HDF C) add_subdirectory (hdf5lib) diff --git a/java/src/hdf/hdf5lib/CMakeLists.txt b/java/src/hdf/hdf5lib/CMakeLists.txt index be8f60a..e07f210 100644 --- a/java/src/hdf/hdf5lib/CMakeLists.txt +++ b/java/src/hdf/hdf5lib/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_JAVA_HDF_HDF5 Java) set (CMAKE_VERBOSE_MAKEFILE 1) diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index ce6e7d4..7681c48 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -1107,7 +1107,9 @@ public class H5 implements java.io.Serializable { log.trace("H5Aread_dname_D"); status = H5Aread_double(attr_id, mem_type_id, (double[]) obj, isCriticalPinning); } - else if ((H5.H5Tdetect_class(mem_type_id, HDF5Constants.H5T_REFERENCE) && (is1D && (dataClass.getComponentType() == String.class))) || H5.H5Tequal(mem_type_id, HDF5Constants.H5T_STD_REF_DSETREG)) { + else if ((H5.H5Tdetect_class(mem_type_id, HDF5Constants.H5T_REFERENCE) && + (is1D && (dataClass.getComponentType() == String.class))) || + H5.H5Tequal(mem_type_id, HDF5Constants.H5T_STD_REF_DSETREG)) { log.trace("H5Aread_reg_ref"); status = H5Aread_reg_ref(attr_id, mem_type_id, (String[]) obj); } @@ -2005,7 +2007,9 @@ public class H5 implements java.io.Serializable { status = H5Dread_double(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (double[]) obj, isCriticalPinning); } - else if ((H5.H5Tdetect_class(mem_type_id, HDF5Constants.H5T_REFERENCE) && (is1D && (dataClass.getComponentType() == String.class))) || H5.H5Tequal(mem_type_id, HDF5Constants.H5T_STD_REF_DSETREG)) { + else if ((H5.H5Tdetect_class(mem_type_id, HDF5Constants.H5T_REFERENCE) && + (is1D && (dataClass.getComponentType() == String.class))) || + H5.H5Tequal(mem_type_id, HDF5Constants.H5T_STD_REF_DSETREG)) { log.trace("H5Dread_reg_ref"); status = H5Dread_reg_ref(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (String[]) obj); @@ -3563,7 +3567,7 @@ public class H5 implements java.io.Serializable { public synchronized static int H5Gget_obj_info_all(long loc_id, String name, String[] oname, int[] otype, int[] ltype, long[] fno, long[] ref, int indx_type) throws HDF5LibraryException, NullPointerException { - return H5Gget_obj_info_full(loc_id, name, oname, otype, ltype, fno, ref, oname.length, indx_type, -1); + return H5Gget_obj_info_full(loc_id, name, oname, otype, ltype, fno, ref, indx_type, -1); } public synchronized static int H5Gget_obj_info_full(long loc_id, String name, String[] oname, int[] otype, diff --git a/java/src/hdf/hdf5lib/structs/H5O_hdr_info_t.java b/java/src/hdf/hdf5lib/structs/H5O_hdr_info_t.java index a39c1ed..8d0cc24 100644 --- a/java/src/hdf/hdf5lib/structs/H5O_hdr_info_t.java +++ b/java/src/hdf/hdf5lib/structs/H5O_hdr_info_t.java @@ -16,7 +16,7 @@ package hdf.hdf5lib.structs; import java.io.Serializable; // Information struct for object header metadata (for H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx) -public class H5O_hdr_info_t implements Serializable{ +public class H5O_hdr_info_t implements Serializable { private static final long serialVersionUID = 7883826382952577189L; public int version; /* Version number of header format in file */ public int nmesgs; /* Number of object header messages */ @@ -44,4 +44,38 @@ public class H5O_hdr_info_t implements Serializable{ this.mesg_present = mesg_present; this.mesg_shared = mesg_shared; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + + if (!(o instanceof H5O_hdr_info_t)) + return false; + + H5O_hdr_info_t info = (H5O_hdr_info_t) o; + + if (this.version != info.version) + return false; + if (this.nmesgs != info.nmesgs) + return false; + if (this.nchunks != info.nchunks) + return false; + if (this.flags != info.flags) + return false; + if (this.space_total != info.space_total) + return false; + if (this.space_meta != info.space_meta) + return false; + if (this.space_mesg != info.space_mesg) + return false; + if (this.space_free != info.space_free) + return false; + if (this.mesg_present != info.mesg_present) + return false; + if (this.mesg_shared != info.mesg_shared) + return false; + + return true; + } } diff --git a/java/src/hdf/hdf5lib/structs/H5O_info_t.java b/java/src/hdf/hdf5lib/structs/H5O_info_t.java index ac32f6a..5dd078f 100644 --- a/java/src/hdf/hdf5lib/structs/H5O_info_t.java +++ b/java/src/hdf/hdf5lib/structs/H5O_info_t.java @@ -15,8 +15,8 @@ package hdf.hdf5lib.structs; import java.io.Serializable; -//Information struct for object (for H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx) -public class H5O_info_t implements Serializable{ +// Information struct for object (for H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx) +public class H5O_info_t implements Serializable { private static final long serialVersionUID = 4691681163544054518L; public long fileno; /* File number that object is located in */ public long addr; /* Object address in file */ diff --git a/java/src/hdf/hdf5lib/structs/H5_ih_info_t.java b/java/src/hdf/hdf5lib/structs/H5_ih_info_t.java index ea36d85..7159f02 100644 --- a/java/src/hdf/hdf5lib/structs/H5_ih_info_t.java +++ b/java/src/hdf/hdf5lib/structs/H5_ih_info_t.java @@ -26,4 +26,22 @@ public class H5_ih_info_t implements Serializable { this.index_size = index_size; this.heap_size = heap_size; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + + if (!(o instanceof H5_ih_info_t)) + return false; + + H5_ih_info_t info = (H5_ih_info_t) o; + + if (this.index_size != info.index_size) + return false; + if (this.heap_size != info.heap_size) + return false; + + return true; + } } diff --git a/java/src/jni/CMakeLists.txt b/java/src/jni/CMakeLists.txt index 366f091..386a908 100644 --- a/java/src/jni/CMakeLists.txt +++ b/java/src/jni/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_JAVA_JNI C) set (HDF5_JAVA_JNI_CSRCS diff --git a/java/src/jni/exceptionImp.c b/java/src/jni/exceptionImp.c index 0faa0cc..c08b67b 100644 --- a/java/src/jni/exceptionImp.c +++ b/java/src/jni/exceptionImp.c @@ -409,7 +409,7 @@ h5libraryError if (msg_size > 0) { if (NULL == (msg_str = (char *) HDcalloc((size_t)msg_size + 1, sizeof(char)))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5libraryerror: failed to allocate buffer for error message"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5libraryerror: failed to allocate buffer for error message"); if ((msg_size = H5Eget_msg(min_num, &error_msg_type, msg_str, (size_t)msg_size + 1)) < 0) goto done; diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c index eaa356e..4dfbe39 100644 --- a/java/src/jni/h5aImp.c +++ b/java/src/jni/h5aImp.c @@ -825,10 +825,10 @@ Java_hdf_hdf5lib_H5_H5Aread_1string H5_LIBRARY_ERROR(ENVONLY); if (NULL == (cstr = (char *) HDmalloc(str_len + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_string: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_string: memory allocation failed"); if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_string: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_string: memory allocation failed"); if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, c_buf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -839,7 +839,7 @@ Java_hdf_hdf5lib_H5_H5Aread_1string if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, cstr))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_string: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_string: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, j_buf, i, jstr); @@ -889,7 +889,7 @@ Java_hdf_hdf5lib_H5_H5Awrite_1string H5_LIBRARY_ERROR(ENVONLY); if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Awrite_string: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Awrite_string: memory allocation failed"); for (i = 0; i < (size_t) n; i++) { if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)j_buf, (jsize) i))) { @@ -1021,7 +1021,7 @@ H5AreadVL_str } if (NULL == (strs = (char **) HDcalloc((size_t)n, sizeof(char *)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadVL_str: failed to allocate variable length string read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadVL_str: failed to allocate variable length string read buffer"); if ((status = H5Aread(aid, tid, strs)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1094,7 +1094,7 @@ H5AreadVL_asstr H5_LIBRARY_ERROR(ENVONLY); if (NULL == (readBuf = HDcalloc((size_t)n, typeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadVL_asstr: failed to allocate read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadVL_asstr: failed to allocate read buffer"); if ((status = H5Aread(aid, tid, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1103,7 +1103,7 @@ H5AreadVL_asstr h5str_new(&h5str, 4 * typeSize); if (!h5str.s) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadVL_asstr: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadVL_asstr: failed to allocate buffer"); /* Convert each element to a char string */ for (i = 0; i < (size_t) n; i++) { @@ -1227,7 +1227,7 @@ H5AwriteVL_str } if (NULL == (writeBuf = (char **) HDcalloc((size_t)size + 1, sizeof(char *)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AwriteVL_str: failed to allocate variable length string write buffer") + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AwriteVL_str: failed to allocate variable length string write buffer"); for (i = 0; i < size; ++i) { jsize length; @@ -1248,7 +1248,7 @@ H5AwriteVL_str PIN_JAVA_STRING(ENVONLY, obj, utf8, NULL, "H5AwriteVL_str: string not pinned"); if (NULL == (writeBuf[i] = (char *) HDmalloc((size_t)length + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AwriteVL_str: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AwriteVL_str: failed to allocate string buffer"); HDstrncpy(writeBuf[i], utf8, (size_t)length); writeBuf[i][length] = '\0'; @@ -1288,7 +1288,7 @@ H5AwriteVL_asstr { const char *utf8 = NULL; hsize_t dims[H5S_MAX_RANK]; - jstring jstr; + jstring jstr = NULL; size_t typeSize; size_t i; hid_t sid = H5I_INVALID_HID; @@ -1309,7 +1309,7 @@ H5AwriteVL_asstr H5_LIBRARY_ERROR(ENVONLY); if (NULL == (writeBuf = HDcalloc((size_t)n, typeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AwriteVL_asstr: failed to allocate write buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AwriteVL_asstr: failed to allocate write buffer"); /* * When repeatedly writing a dataset with a large number of strs (e.g., 1,000,000 strings), @@ -1390,7 +1390,7 @@ Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref } if (NULL == (ref_data = (hdset_reg_ref_t *) HDcalloc(1, (size_t)n * sizeof(hdset_reg_ref_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_reg_ref: failed to allocate read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_reg_ref: failed to allocate read buffer"); if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, ref_data)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1398,7 +1398,7 @@ Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref h5str_new(&h5str, 1024); if (!h5str.s) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_reg_ref: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_reg_ref: failed to allocate buffer"); for (i = 0; i < n; i++) { h5str.s[0] = '\0'; @@ -1483,7 +1483,7 @@ Java_hdf_hdf5lib_H5_H5Aget_1name H5_LIBRARY_ERROR(ENVONLY); if (NULL == (attrName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aget_name: failed to allocate attribute name buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aget_name: failed to allocate attribute name buffer"); if (H5Aget_name((hid_t)attr_id, (size_t)buf_size + 1, attrName) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1835,7 +1835,7 @@ Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx H5_LIBRARY_ERROR(ENVONLY); if (NULL == (attrName = (char *) HDmalloc(sizeof(char) * (size_t) status_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Aget_name_by_idx: failed to allocate buffer for attribute name"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aget_name_by_idx: failed to allocate buffer for attribute name"); if ((H5Aget_name_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, (H5_iter_order_t) order, (hsize_t) n, (char *)attrName, (size_t)status_size + 1, (hid_t)lapl_id)) < 0) @@ -2141,7 +2141,7 @@ static herr_t H5A_iterate_cb (hid_t g_id, const char *name, const H5A_info_t *info, void *cb_data) { cb_wrapper *wrapper = (cb_wrapper *)cb_data; - jmethodID constructor, mid; + jmethodID mid; jobject cb_info_t = NULL; jobject visit_callback = wrapper->visit_callback; jstring str; @@ -2170,18 +2170,7 @@ H5A_iterate_cb args[2].i = info->cset; args[3].j = (jlong)info->data_size; - /* Get a reference to your class if you don't have it already */ - if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5A_info_t"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - /* Get a reference to the constructor; the name is <init> */ - if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(ZJIJ)V"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { - HDprintf("FATAL ERROR: hdf/hdf5lib/structs/H5A_info_t: Creation failed\n"); - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - } + CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args, cb_info_t); status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, g_id, str, cb_info_t, op_data); CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c index 5500847..5b53460 100644 --- a/java/src/jni/h5dImp.c +++ b/java/src/jni/h5dImp.c @@ -963,10 +963,10 @@ Java_hdf_hdf5lib_H5_H5Dread_1string H5_LIBRARY_ERROR(ENVONLY); if (NULL == (cstr = (char *) HDmalloc(str_len + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_string: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_string: memory allocation failed"); if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_string: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_string: memory allocation failed"); if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, c_buf)) < 0) @@ -978,7 +978,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1string if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, cstr))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_string: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_string: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, j_buf, i, jstr); @@ -1029,7 +1029,7 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1string H5_LIBRARY_ERROR(ENVONLY); if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dwrite_string: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dwrite_string: memory allocation failed"); for (i = 0; i < (size_t) n; i++) { if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)j_buf, (jsize) i))) { @@ -1165,7 +1165,7 @@ H5DreadVL_str } if (NULL == (strs = (char **) HDcalloc((size_t)n, sizeof(char *)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5DreadVL_str: failed to allocate variable length string read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DreadVL_str: failed to allocate variable length string read buffer"); if ((status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, strs)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1251,7 +1251,7 @@ H5DreadVL_asstr H5_LIBRARY_ERROR(ENVONLY); if (NULL == (readBuf = HDcalloc((size_t)n, typeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5DreadVL_asstr: failed to allocate read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DreadVL_asstr: failed to allocate read buffer"); if ((status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1260,7 +1260,7 @@ H5DreadVL_asstr h5str_new(&h5str, 4 * typeSize); if (!h5str.s) - H5_JNI_FATAL_ERROR(ENVONLY, "H5DreadVL_asstr: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DreadVL_asstr: failed to allocate buffer"); if ((tclass = H5Tget_class(tid)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1430,7 +1430,7 @@ H5DwriteVL_str } if (NULL == (writeBuf = (char **) HDcalloc((size_t)size + 1, sizeof(char *)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5DwriteVL_str: failed to allocate variable length string write buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DwriteVL_str: failed to allocate variable length string write buffer"); for (i = 0; i < size; ++i) { jsize length; @@ -1451,7 +1451,7 @@ H5DwriteVL_str PIN_JAVA_STRING(ENVONLY, obj, utf8, NULL, "H5DwriteVL_str: string not pinned"); if (NULL == (writeBuf[i] = (char *) HDmalloc((size_t)length + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5DwriteVL_str: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DwriteVL_str: failed to allocate string buffer"); HDstrncpy(writeBuf[i], utf8, (size_t)length + 1); writeBuf[i][length] = '\0'; @@ -1490,7 +1490,7 @@ H5DwriteVL_asstr (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf) { const char *utf8 = NULL; - jstring obj; + jstring obj = NULL; hbool_t close_mem_space = FALSE; size_t typeSize; size_t i; @@ -1524,7 +1524,7 @@ H5DwriteVL_asstr H5_LIBRARY_ERROR(ENVONLY); if (NULL == (writeBuf = HDcalloc((size_t)n, typeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AwriteVL_asstr: failed to allocate write buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AwriteVL_asstr: failed to allocate write buffer"); for (i = 0; i < (size_t) n; ++i) { if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)buf, (jsize) i))) { @@ -1634,7 +1634,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref } if (NULL == (ref_data = (hdset_reg_ref_t *) HDcalloc(1, (size_t)n * sizeof(hdset_reg_ref_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_reg_ref: failed to allocate read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_reg_ref: failed to allocate read buffer"); if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, xfer_plist_id, ref_data)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1642,7 +1642,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref h5str_new(&h5str, 1024); if (!h5str.s) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_reg_ref: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_reg_ref: failed to allocate buffer"); for (i = 0; i < n; i++) { h5str.s[0] = '\0'; @@ -1897,7 +1897,7 @@ Java_hdf_hdf5lib_H5_H5Dset_1extent PIN_LONG_ARRAY(ENVONLY, buf, dimsBuf, &isCopy, "H5Dset_extent: buffer not pinned"); if (NULL == (dims = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dset_extent: failed to allocate dataset dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dset_extent: failed to allocate dataset dimension buffer"); for (i = 0; i < rank; i++) dims[i] = (hsize_t)dimsBuf[i]; diff --git a/java/src/jni/h5eImp.c b/java/src/jni/h5eImp.c index 937323e..7ea4223 100644 --- a/java/src/jni/h5eImp.c +++ b/java/src/jni/h5eImp.c @@ -309,7 +309,7 @@ Java_hdf_hdf5lib_H5_H5Eget_1class_1name H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_class_name: no class name"); if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Eget_class_name: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Eget_class_name: malloc failed"); if ((H5Eget_class_name((hid_t)cls_id, (char *)namePtr, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -464,10 +464,10 @@ Java_hdf_hdf5lib_H5_H5Eget_1msg H5_LIBRARY_ERROR(ENVONLY); if (!buf_size) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Eget_msg: invalid message"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_msg: invalid message"); if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Eget_msg: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Eget_msg: malloc failed"); PIN_INT_ARRAY(ENVONLY, error_msg_type_list, theArray, NULL, "H5Eget_msg: error_msg_type_list not pinned"); @@ -517,7 +517,6 @@ H5E_walk_cb (int nindx, const H5E_error2_t *info, void *cb_data) { cb_wrapper *wrapper = (cb_wrapper *)cb_data; - jmethodID constructor; jmethodID mid; jobject visit_callback = wrapper->visit_callback; jstring str1, str2, str3; @@ -559,16 +558,7 @@ H5E_walk_cb args[6].l = str3; - /* Get a reference to your class if you don't have it already */ - if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5E_error2_t"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - /* get a reference to the constructor; the name is <init> */ - if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(JJJILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5E_error2_t", "(JJJILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", args, cb_info_t); status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, nindx, cb_info_t, op_data); CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c index 115e8f4..101443e 100644 --- a/java/src/jni/h5fImp.c +++ b/java/src/jni/h5fImp.c @@ -131,7 +131,7 @@ Java_hdf_hdf5lib_H5_H5Fget_1name H5_LIBRARY_ERROR(ENVONLY); if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Fget_name: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Fget_name: malloc failed"); if ((H5Fget_name((hid_t)file_id, namePtr, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -386,7 +386,7 @@ Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids } if (NULL == (id_list = (hid_t *) HDmalloc((size_t)rank * sizeof(hid_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Fget_obj_ids: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Fget_obj_ids: malloc failed"); if ((ret_val = H5Fget_obj_ids((hid_t)file_id, (unsigned int)types, (size_t)maxObjs, id_list)) < 0) H5_LIBRARY_ERROR(ENVONLY); diff --git a/java/src/jni/h5iImp.c b/java/src/jni/h5iImp.c index a367802..e8030aee 100644 --- a/java/src/jni/h5iImp.c +++ b/java/src/jni/h5iImp.c @@ -71,7 +71,7 @@ Java_hdf_hdf5lib_H5_H5Iget_1name_1long H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Iget_name_long: buf_size < 0"); if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Iget_name_long: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Iget_name_long: malloc failed"); if ((size = H5Iget_name((hid_t)obj_id, aName, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -111,7 +111,7 @@ Java_hdf_hdf5lib_H5_H5Iget_1name H5_LIBRARY_ERROR(ENVONLY); if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Iget_name: malloc failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Iget_name: malloc failed"); if (H5Iget_name((hid_t)obj_id, aName, (size_t)buf_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); diff --git a/java/src/jni/h5jni.h b/java/src/jni/h5jni.h index 4a94180..f833c71 100644 --- a/java/src/jni/h5jni.h +++ b/java/src/jni/h5jni.h @@ -47,195 +47,6 @@ */ #define UNUSED(o) (void) o -/* Macros for class access */ -/* Calling code must define ret_obj as jobject */ -#define CALL_CONSTRUCTOR(env, classname, classsig, args, ret_obj) \ -{ \ - jmethodID constructor; \ - jclass cls; \ - \ - if (NULL == (cls = ENVPTR->FindClass(env, (classname)))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, "JNI error: GetObjectClass"); \ - } \ - if (NULL == (constructor = ENVPTR->GetMethodID(ENVONLY, cls, "<init>", (classsig)))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, "JNI error: GetMethodID failed"); \ - } \ - if (NULL == (ret_obj = ENVPTR->NewObjectA(ENVONLY, cls, constructor, (args)))) { \ - CHECK_JNI_EXCEPTION(env, JNI_FALSE); \ - } \ -} - -/* - * Macros for pinning/unpinning objects. - */ -#define PIN_BYTE_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetByteArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_BYTE_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jbyte *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_BYTE_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseByteArrayElements(env, pinnedArray, (jbyte *) bufToRelease, freeMode); \ -} - -#define PIN_SHORT_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetShortArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_SHORT_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jshort *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_SHORT_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseShortArrayElements(env, pinnedArray, (jshort *) bufToRelease, freeMode); \ -} - -#define PIN_INT_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetIntArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_INT_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jint *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_INT_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseIntArrayElements(env, pinnedArray, (jint *) bufToRelease, freeMode); \ -} - -#define PIN_LONG_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetLongArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_LONG_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jlong *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_LONG_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseLongArrayElements(env, pinnedArray, (jlong *) bufToRelease, freeMode); \ -} - -#define PIN_FLOAT_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetFloatArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_FLOAT_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jfloat *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_FLOAT_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseFloatArrayElements(env, pinnedArray, (jfloat *) bufToRelease, freeMode); \ -} - -#define PIN_DOUBLE_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetDoubleArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_DOUBLE_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jdouble *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_DOUBLE_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseDoubleArrayElements(env, pinnedArray, (jdouble *) bufToRelease, freeMode); \ -} - -#define PIN_BOOL_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = ENVPTR->GetBooleanArrayElements(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define PIN_BOOL_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ -{ \ - if (NULL == (outBuf = (jboolean *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_BOOL_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleaseBooleanArrayElements(env, pinnedArray, (jboolean *) bufToRelease, freeMode); \ -} - -#define UNPIN_ARRAY_CRITICAL(env, pinnedArray, bufToRelease, freeMode) \ -{ \ - ENVPTR->ReleasePrimitiveArrayCritical(env, pinnedArray, bufToRelease, freeMode); \ -} - -/* Macros for string access */ -#define PIN_JAVA_STRING(env, stringToPin, outString, isCopy, failErrMsg) \ -{ \ - if (NULL == (outString = ENVPTR->GetStringUTFChars(env, stringToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(env, failErrMsg); \ - } \ -} - -#define UNPIN_JAVA_STRING(env, pinnedString, stringToRelease) \ -{ \ - ENVPTR->ReleaseStringUTFChars(env, pinnedString, stringToRelease); \ -} - /* * Macro to check for a JNI exception after a JNI method is called. * If an exception occurred, the value of 'clearException' will determine @@ -246,15 +57,205 @@ * cleanup+return section of the native method, since at that point * cleaning up and returning is the only safe thing that can be done. */ -#define CHECK_JNI_EXCEPTION(env, clearException) \ -{ \ - if (JNI_TRUE == (*env)->ExceptionCheck(env)) { \ - if (JNI_TRUE == clearException) \ - (*env)->ExceptionClear(env); \ - else \ - goto done; \ - } \ -} +#define CHECK_JNI_EXCEPTION(envptr, clearException) \ +do { \ + if (JNI_TRUE == (*envptr)->ExceptionCheck(envptr)) { \ + if (JNI_TRUE == clearException) \ + (*envptr)->ExceptionClear(envptr); \ + else \ + goto done; \ + } \ +} while(0) + +/* Macros for class access */ +/* Calling code must define ret_obj as jobject */ +#define CALL_CONSTRUCTOR(envptr, classname, classsig, args, ret_obj) \ +do { \ + jmethodID constructor; \ + jclass cls; \ + \ + if (NULL == (cls = (*envptr)->FindClass(envptr, (classname)))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, "JNI error: GetObjectClass"); \ + } \ + if (NULL == (constructor = (*envptr)->GetMethodID(envptr, cls, "<init>", (classsig)))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, "JNI error: GetMethodID failed"); \ + } \ + if (NULL == (ret_obj = (*envptr)->NewObjectA(envptr, cls, constructor, (args)))) { \ + HDprintf("FATAL ERROR: %s: Creation failed\n", classname); \ + CHECK_JNI_EXCEPTION(envptr, JNI_FALSE); \ + } \ +} while(0) + +/* + * Macros for pinning/unpinning objects. + */ +#define PIN_BYTE_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetByteArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_BYTE_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jbyte *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_BYTE_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseByteArrayElements(envptr, pinnedArray, (jbyte *) bufToRelease, freeMode); \ +} while(0) + +#define PIN_SHORT_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetShortArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_SHORT_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jshort *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_SHORT_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseShortArrayElements(envptr, pinnedArray, (jshort *) bufToRelease, freeMode); \ +} while(0) + +#define PIN_INT_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetIntArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_INT_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jint *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_INT_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseIntArrayElements(envptr, pinnedArray, (jint *) bufToRelease, freeMode); \ +} while(0) + +#define PIN_LONG_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetLongArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_LONG_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jlong *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_LONG_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseLongArrayElements(envptr, pinnedArray, (jlong *) bufToRelease, freeMode); \ +} while(0) + +#define PIN_FLOAT_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetFloatArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_FLOAT_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jfloat *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_FLOAT_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseFloatArrayElements(envptr, pinnedArray, (jfloat *) bufToRelease, freeMode); \ +} while(0) + +#define PIN_DOUBLE_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetDoubleArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_DOUBLE_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jdouble *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_DOUBLE_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseDoubleArrayElements(envptr, pinnedArray, (jdouble *) bufToRelease, freeMode); \ +} while(0) + +#define PIN_BOOL_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (*envptr)->GetBooleanArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define PIN_BOOL_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ +do { \ + if (NULL == (outBuf = (jboolean *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_BOOL_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleaseBooleanArrayElements(envptr, pinnedArray, (jboolean *) bufToRelease, freeMode); \ +} while(0) + +#define UNPIN_ARRAY_CRITICAL(envptr, pinnedArray, bufToRelease, freeMode) \ +do { \ + (*envptr)->ReleasePrimitiveArrayCritical(envptr, pinnedArray, bufToRelease, freeMode); \ +} while(0) + +/* Macros for string access */ +#define PIN_JAVA_STRING(envptr, stringToPin, outString, isCopy, failErrMsg) \ +do { \ + if (NULL == (outString = (*envptr)->GetStringUTFChars(envptr, stringToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ +} while(0) + +#define UNPIN_JAVA_STRING(envptr, pinnedString, stringToRelease) \ +do { \ + (*envptr)->ReleaseStringUTFChars(envptr, pinnedString, stringToRelease); \ +} while(0) #ifdef __cplusplus extern "C" { @@ -279,46 +280,46 @@ extern jboolean h5unimplemented( JNIEnv *env, const char *functName); * then do its own error handling, but we instead opt to immediately return. */ #define H5_JNI_FATAL_ERROR(env, message) \ -{ \ +do { \ h5JNIFatalError(env, message); \ goto done; \ -} +} while(0) #define H5_NULL_ARGUMENT_ERROR(env, message) \ -{ \ +do { \ h5nullArgument(env, message); \ goto done; \ -} +} while(0) #define H5_BAD_ARGUMENT_ERROR(env, message) \ -{ \ +do { \ h5badArgument(env, message); \ goto done; \ -} +} while(0) #define H5_OUT_OF_MEMORY_ERROR(env, message) \ -{ \ +do { \ h5outOfMemory(env, message); \ goto done; \ -} +} while(0) #define H5_LIBRARY_ERROR(env) \ -{ \ +do { \ h5libraryError(env); \ goto done; \ -} +} while(0) #define H5_RAISE_EXCEPTION(env, message, exception) \ -{ \ +do { \ h5raiseException(env, message, exception); \ goto done; \ -} +} while(0) #define H5_UNIMPLEMENTED(env, message) \ -{ \ +do { \ h5unimplemented(env, message); \ goto done; \ -} +} while(0) /* implemented at H5.c */ extern jint get_enum_value(JNIEnv *env, jobject enum_obj); diff --git a/java/src/jni/h5lImp.c b/java/src/jni/h5lImp.c index 7eee3d4..6b55b46 100644 --- a/java/src/jni/h5lImp.c +++ b/java/src/jni/h5lImp.c @@ -381,7 +381,7 @@ Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx /* add extra space for the null terminator */ if (NULL == (linkName = (char *) HDmalloc(sizeof(char) * (size_t)status_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_name_by_idx: failed to allocate buffer for link name"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Lget_name_by_idx: failed to allocate buffer for link name"); if ((H5Lget_name_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char *)linkName, (size_t)status_size + 1, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -430,10 +430,10 @@ Java_hdf_hdf5lib_H5_H5Lget_1value H5_LIBRARY_ERROR(ENVONLY); if (H5L_TYPE_HARD == infobuf.type) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val: hard links are unsupported"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Lget_val: hard links are unsupported"); if (NULL == (linkValue = (char *) HDmalloc(sizeof(char) * infobuf.u.val_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val: failed to allocate buffer for link value"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Lget_val: failed to allocate buffer for link value"); if ((status = H5Lget_val((hid_t)loc_id, linkName, (void *)linkValue, infobuf.u.val_size + 1, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -475,7 +475,7 @@ Java_hdf_hdf5lib_H5_H5Lget_1value case H5L_TYPE_MAX: case H5L_TYPE_HARD: default: - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val: invalid link type"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Lget_val: invalid link type"); break; } @@ -520,13 +520,13 @@ Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx H5_LIBRARY_ERROR(ENVONLY); if (H5L_TYPE_HARD == infobuf.type) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val_by_idx: hard links are unsupported") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Lget_val_by_idx: hard links are unsupported"); if (!infobuf.u.val_size) H5_LIBRARY_ERROR(ENVONLY); if (NULL == (linkValue = (void *) HDmalloc(infobuf.u.val_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val_by_idx: failed to allocate buffer for link value"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Lget_val_by_idx: failed to allocate buffer for link value"); if ((status = H5Lget_val_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (void *)linkValue, infobuf.u.val_size + 1, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -568,7 +568,7 @@ Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx case H5L_TYPE_MAX: case H5L_TYPE_HARD: default: - H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val_by_idx: invalid link type"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Lget_val_by_idx: invalid link type"); break; } @@ -620,7 +620,7 @@ H5L_iterate_cb (hid_t g_id, const char *name, const H5L_info_t *info, void *cb_data) { cb_wrapper *wrapper = (cb_wrapper *)cb_data; - jmethodID constructor, mid; + jmethodID mid; jobject cb_info_t = NULL; jobject visit_callback = wrapper->visit_callback; jstring str; @@ -635,6 +635,7 @@ H5L_iterate_cb H5_JNI_FATAL_ERROR(CBENVONLY, "H5L_iterate_cb: failed to attach current thread to JVM"); } + /* Get the Method ID for the "callback" function of the H5L_iterate_t class */ if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); @@ -649,19 +650,7 @@ H5L_iterate_cb args[2].j = info->corder; args[3].i = info->cset; args[4].j = (info->type == H5L_TYPE_HARD) ? (jlong)info->u.address : (jlong)info->u.val_size; - - /* Get a reference to your class if you don't have it already */ - if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5L_info_t"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - /* Get a reference to the constructor; the name is <init> */ - if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(IZJIJ)V"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { - HDprintf("FATAL ERROR: hdf/hdf5lib/structs/H5L_info_t: Creation failed\n"); - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - } + CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args, cb_info_t); status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, g_id, str, cb_info_t, op_data); CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); diff --git a/java/src/jni/h5oImp.c b/java/src/jni/h5oImp.c index b49a3e9..e332615 100644 --- a/java/src/jni/h5oImp.c +++ b/java/src/jni/h5oImp.c @@ -467,17 +467,7 @@ H5O_iterate_cb args[11].l = ihinfobuf2; /* Get a reference to the H5O_info_t class */ - if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5O_info_t"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - /* Get a reference to the constructor; the name is <init> */ - if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "<init>", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V"))) - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - - if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { - HDprintf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5O_info_t: Creation failed\n"); - CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - } + CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, cb_info_t) ; status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, g_id, str, cb_info_t, op_data); CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); @@ -639,7 +629,7 @@ Java_hdf_hdf5lib_H5_H5Oget_1comment if (buf_size) { if (NULL == (oComment = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Oget_comment: failed to allocate object comment buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Oget_comment: failed to allocate object comment buffer"); if ((status = H5Oget_comment((hid_t)loc_id, oComment, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -684,7 +674,7 @@ Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name if (buf_size) { if (NULL == (objComment = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Oget_comment_by_name: failed to allocate buffer for object comment"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Oget_comment_by_name: failed to allocate buffer for object comment"); if ((status = H5Oget_comment_by_name((hid_t)loc_id, objName, objComment, (size_t)buf_size + 1, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); diff --git a/java/src/jni/h5pDAPLImp.c b/java/src/jni/h5pDAPLImp.c index fb39b84..2386df1 100644 --- a/java/src/jni/h5pDAPLImp.c +++ b/java/src/jni/h5pDAPLImp.c @@ -151,7 +151,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix H5_LIBRARY_ERROR(ENVONLY); if (NULL == (pre = (char *) HDmalloc(sizeof(char) * (size_t)prefix_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_efile_prefix: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_efile_prefix: memory allocation failed"); if (H5Pget_efile_prefix((hid_t)dapl_id, (char *)pre, (size_t)prefix_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -159,7 +159,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, pre))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_efile_prefix: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_efile_prefix: out of memory - unable to construct string from UTF characters"); } done: diff --git a/java/src/jni/h5pDCPLImp.c b/java/src/jni/h5pDCPLImp.c index 7559c3b..f5bbcb1 100644 --- a/java/src/jni/h5pDCPLImp.c +++ b/java/src/jni/h5pDCPLImp.c @@ -109,7 +109,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1chunk PIN_BYTE_ARRAY(ENVONLY, dim, theArray, &isCopy, "H5Pset_chunk: dim array not pinned"); if (NULL == (da = lp = (hsize_t *) HDmalloc(rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pset_chunk: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pset_chunk: memory allocation failed"); jlp = (jlong *)theArray; for (i = 0; i < rank; i++) { @@ -161,7 +161,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1chunk PIN_LONG_ARRAY(ENVONLY, dims, theArray, &isCopy, "H5Pget_chunk: input dims not pinned"); if (NULL == (da = (hsize_t *) HDmalloc((size_t)max_ndims * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_chunk: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_chunk: memory allocation failed"); if ((status = H5Pget_chunk((hid_t)plist, (int)max_ndims, da)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -595,7 +595,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter: cd_values is NULL"); if (NULL == (filter = (char *) HDmalloc(sizeof(char) * (size_t)namelen))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter: memory allocation failed"); PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter: flags array not pinned"); PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter: nelmts array not pinned"); @@ -620,7 +620,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, filter))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -632,7 +632,7 @@ done: if (cd_nelmtsArray) UNPIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, (status < 0) ? JNI_ABORT : 0); if (flagsArray) - UNPIN_INT_ARRAY(ENVONLY, flags, flagsArray, (status < 0) ? JNI_ABORT : 0) + UNPIN_INT_ARRAY(ENVONLY, flags, flagsArray, (status < 0) ? JNI_ABORT : 0); if (filter) HDfree(filter); @@ -671,7 +671,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter2 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter2: filter_config is NULL"); if (NULL == (filter = (char *) HDmalloc(sizeof(char) * (size_t)namelen))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter2: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter2: memory allocation failed"); PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter2: flags array not pinned"); PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter2: nelmts array not pinned"); @@ -715,7 +715,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter2 if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, filter))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter2: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter2: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -772,7 +772,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id: name is NULL"); if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)bs))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter_by_id: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter_by_id: memory allocation failed"); PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter_by_id: flags not pinned"); PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter_by_id: cd_nelms not pinned"); @@ -801,7 +801,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, aName))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter_by_id: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter_by_id: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -858,7 +858,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id2: filter_config is NULL"); if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)bs))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter_by_id2: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter_by_id2: memory allocation failed"); PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter_by_id2: flags not pinned"); PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter_by_id2: cd_nelms not pinned"); @@ -882,7 +882,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, aName))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter_by_id2: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter_by_id2: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -1122,7 +1122,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1external if (name_size > 0) if (NULL == (file = (char *) HDmalloc(sizeof(char) * (size_t)name_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_external: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_external: memory allocation failed"); if ((status = H5Pget_external((hid_t) plist, (unsigned)idx, (size_t)name_size, file, (off_t *)&o, (hsize_t *)&s)) < 0) @@ -1140,7 +1140,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1external if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, file))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_external: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_external: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -1237,7 +1237,7 @@ done: */ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) + (JNIEnv *env, jclass clss, jlong dcpl_id, jlong idx) { ssize_t buf_size; char *dname = NULL; @@ -1246,19 +1246,19 @@ Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname UNUSED(clss); /* get the length of the filename */ - if ((buf_size = H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t)index, NULL, 0)) < 0) + if ((buf_size = H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t) idx, NULL, 0)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (NULL == (dname = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_dsetname: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_dsetname: memory allocation failed"); - if (H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t)index, dname, (size_t)buf_size + 1) < 0) + if (H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t) idx, dname, (size_t)buf_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); dname[buf_size] = '\0'; if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, dname))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_dsetname: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_dsetname: out of memory - unable to construct string from UTF characters"); } done: @@ -1275,7 +1275,7 @@ done: */ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) + (JNIEnv *env, jclass clss, jlong dcpl_id, jlong idx) { ssize_t buf_size; char *fname = NULL; @@ -1284,19 +1284,19 @@ Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename UNUSED(clss); /* get the length of the filename */ - if ((buf_size = H5Pget_virtual_filename((hid_t)dcpl_id, (size_t)index, NULL, 0)) < 0) + if ((buf_size = H5Pget_virtual_filename((hid_t)dcpl_id, (size_t) idx, NULL, 0)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (NULL == (fname = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_filename: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_filename: memory allocation failed"); - if (H5Pget_virtual_filename((hid_t)dcpl_id, (size_t)index, fname, (size_t)buf_size + 1) < 0) + if (H5Pget_virtual_filename((hid_t)dcpl_id, (size_t) idx, fname, (size_t)buf_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); fname[buf_size] = '\0'; if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, fname))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_filename: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_filename: out of memory - unable to construct string from UTF characters"); } done: @@ -1313,13 +1313,13 @@ done: */ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) + (JNIEnv *env, jclass clss, jlong dcpl_id, jlong idx) { hid_t space_id = H5I_INVALID_HID; UNUSED(clss); - if ((space_id = H5Pget_virtual_srcspace((hid_t)dcpl_id, (size_t)index)) < 0) + if ((space_id = H5Pget_virtual_srcspace((hid_t)dcpl_id, (size_t) idx)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1333,13 +1333,13 @@ done: */ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) + (JNIEnv *env, jclass clss, jlong dcpl_id, jlong idx) { hid_t space_id = H5I_INVALID_HID; UNUSED(clss); - if ((space_id = H5Pget_virtual_vspace((hid_t)dcpl_id, (size_t)index)) < 0) + if ((space_id = H5Pget_virtual_vspace((hid_t)dcpl_id, (size_t) idx)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1392,7 +1392,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix H5_LIBRARY_ERROR(ENVONLY); if (NULL == (pre = (char *) HDmalloc(sizeof(char) * (size_t) prefix_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_prefix: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_prefix: memory allocation failed"); if (H5Pget_virtual_prefix((hid_t)dapl_id, (char *)pre, (size_t) prefix_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1400,7 +1400,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, pre))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_prefix: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_prefix: out of memory - unable to construct string from UTF characters"); } done: diff --git a/java/src/jni/h5pDXPLImp.c b/java/src/jni/h5pDXPLImp.c index 323fa8c..12e3367 100644 --- a/java/src/jni/h5pDXPLImp.c +++ b/java/src/jni/h5pDXPLImp.c @@ -310,7 +310,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1data_1transform H5_LIBRARY_ERROR(ENVONLY); if (NULL == (express = (char *) HDmalloc(sizeof(char) * (size_t)express_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_data_transform: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_data_transform: memory allocation failed"); if (H5Pget_data_transform((hid_t)plist_id, express, (size_t)express_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -318,7 +318,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1data_1transform if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, express))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_data_transform: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_data_transform: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, expression, 0, str); diff --git a/java/src/jni/h5pFAPLImp.c b/java/src/jni/h5pFAPLImp.c index 006707a..9ae8775 100644 --- a/java/src/jni/h5pFAPLImp.c +++ b/java/src/jni/h5pFAPLImp.c @@ -308,7 +308,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family } if (NULL == (sa = (hsize_t *) HDmalloc((size_t) rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_family: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_family: memory allocation failed"); PIN_LONG_ARRAY(ENVONLY, memb_plist, plistArray, &isCopy, "H5Pget_family: plistArray not pinned"); @@ -395,29 +395,23 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1hdfs if (H5Pget_fapl_hdfs((hid_t)fapl_id, &fa) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL != fa.namenode_name) { - if (NULL == (j_namenode_name = ENVPTR->NewStringUTF(ENVONLY, fa.namenode_name))) { - CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create namenode_name string"); - } + if (NULL == (j_namenode_name = ENVPTR->NewStringUTF(ENVONLY, fa.namenode_name))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create namenode_name string"); } args[0].l = j_namenode_name; args[1].i = (jint)fa.namenode_port; - if (NULL != fa.user_name) { - if (NULL == (j_user_name = ENVPTR->NewStringUTF(ENVONLY, fa.user_name))) { - CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create user_name string"); - } + if (NULL == (j_user_name = ENVPTR->NewStringUTF(ENVONLY, fa.user_name))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create user_name string"); } args[2].l = j_user_name; - if (NULL != fa.kerberos_ticket_cache) { - if (NULL == (j_kerb_cache_path = ENVPTR->NewStringUTF(ENVONLY, fa.kerberos_ticket_cache))) { - CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create kerberos_ticket_cache string"); - } + if (NULL == (j_kerb_cache_path = ENVPTR->NewStringUTF(ENVONLY, fa.kerberos_ticket_cache))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create kerberos_ticket_cache string"); } args[3].l = j_kerb_cache_path; @@ -425,6 +419,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1hdfs CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5FD_hdfs_fapl_t", "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;I)V", args, ret_obj); #else + UNUSED(fapl_id); + H5_UNIMPLEMENTED(ENVONLY, "H5Pget_fapl_hdfs: not implemented"); #endif /* H5_HAVE_LIBHDFS */ @@ -532,6 +528,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1hdfs if (H5Pset_fapl_hdfs((hid_t)fapl_id, &instance) < 0) H5_LIBRARY_ERROR(ENVONLY); #else + UNUSED(fapl_id); + UNUSED(fapl_config); + H5_UNIMPLEMENTED(ENVONLY, "H5Pset_fapl_hdfs: not implemented"); #endif /* H5_HAVE_LIBHDFS */ @@ -646,7 +645,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi str_len = HDstrlen(utf8); if (NULL == (member_name[i] = (char *) HDmalloc(str_len + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pset_fapl_multi: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pset_fapl_multi: memory allocation failed"); HDstrncpy(member_name[i], utf8, str_len + 1); (member_name[i])[str_len] = '\0'; @@ -673,7 +672,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi if (NULL == (rstring = ENVPTR->NewStringUTF(ENVONLY, member_name[i]))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pset_fapl_multi: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pset_fapl_multi: out of memory - unable to construct string from UTF characters"); } if (NULL == (o = ENVPTR->GetObjectArrayElement(ENVONLY, memb_name, (jsize) i))) { @@ -745,7 +744,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi PIN_LONG_ARRAY(ENVONLY, memb_addr, theaddrArray, &isCopy, "H5Pget_fapl_multi: memb_addr not pinned"); if (memb_name) if (NULL == (mName = (char **) HDcalloc(H5FD_MEM_NTYPES, sizeof(*mName)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_multi: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_multi: memory allocation failed"); if ((status = H5Pget_fapl_multi((hid_t)tid, (H5FD_mem_t *)themapArray, (hid_t *)thefaplArray, mName, (haddr_t *)theaddrArray, (hbool_t *)&relax)) < 0) @@ -756,7 +755,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi if (mName[i]) { if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, mName[i]))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_multi: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_multi: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, memb_name, (jsize) i, (jobject)str); @@ -815,32 +814,28 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1ros3 if (H5Pget_fapl_ros3((hid_t)fapl_id, &fa) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL != fa.aws_region) { - if (NULL == (j_aws = ENVPTR->NewStringUTF(ENVONLY, fa.aws_region))) { - CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_ros3: out of memory - can't create aws_region string"); - } + if (NULL == (j_aws = ENVPTR->NewStringUTF(ENVONLY, fa.aws_region))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_ros3: out of memory - can't create aws_region string"); } args[0].l = j_aws; - if (NULL != fa.secret_id) { - if (NULL == (j_id = ENVPTR->NewStringUTF(ENVONLY, fa.secret_id))) { - CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_ros3: out of memory - can't create secret_id string"); - } + if (NULL == (j_id = ENVPTR->NewStringUTF(ENVONLY, fa.secret_id))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_ros3: out of memory - can't create secret_id string"); } args[1].l = j_id; - if (NULL != fa.secret_key) { - if (NULL == (j_key = ENVPTR->NewStringUTF(ENVONLY, fa.secret_key))) { - CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_ros3: out of memory - can't create secret_key string"); - } + if (NULL == (j_key = ENVPTR->NewStringUTF(ENVONLY, fa.secret_key))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_ros3: out of memory - can't create secret_key string"); } args[2].l = j_key; CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5FD_ros3_fapl_t", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", args, ret_obj); #else + UNUSED(fapl_id); + H5_UNIMPLEMENTED(ENVONLY, "H5Pget_fapl_ros3: not implemented"); #endif /* H5_HAVE_ROS3_VFD */ @@ -939,6 +934,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1ros3 if (H5Pset_fapl_ros3((hid_t)fapl_id, &instance) < 0) H5_LIBRARY_ERROR(ENVONLY); #else + UNUSED(fapl_id); + UNUSED(fapl_config); + H5_UNIMPLEMENTED(ENVONLY, "H5Pset_fapl_ros3: not implemented"); #endif /* H5_HAVE_ROS3_VFD */ @@ -1675,11 +1673,9 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config args[2].z = cacheinfo.open_trace_file; args[3].z = cacheinfo.close_trace_file; - if (NULL != cacheinfo.trace_file_name) { - if (NULL == (j_str = ENVPTR->NewStringUTF(ENVONLY, cacheinfo.trace_file_name))) { - CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_mdc_config: out of memory - unable to construct string from UTF characters"); - } + if (NULL == (j_str = ENVPTR->NewStringUTF(ENVONLY, cacheinfo.trace_file_name))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_mdc_config: out of memory - unable to construct string from UTF characters"); } args[4].l = j_str; @@ -1792,7 +1788,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options location_size++; /* add extra space for the null terminator */ if (NULL == (lname = (char *) HDmalloc(sizeof(char) * location_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_mdc_log_options: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_mdc_log_options: memory allocation failed"); if ((status = H5Pget_mdc_log_options((hid_t)fapl_id, &is_enabled, lname, &location_size, &start_on_access)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1800,7 +1796,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, lname))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_mdc_log_options: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_mdc_log_options: out of memory - unable to construct string from UTF characters"); } mdc_log_options_ptr[0] = (jboolean)is_enabled; diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c index 726e08c..9e5b004 100644 --- a/java/src/jni/h5pImp.c +++ b/java/src/jni/h5pImp.c @@ -503,7 +503,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1class_1name if (NULL == (j_str = ENVPTR->NewStringUTF(ENVONLY, c_str))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_class_name: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_class_name: out of memory - unable to construct string from UTF characters"); } done: diff --git a/java/src/jni/h5pLAPLImp.c b/java/src/jni/h5pLAPLImp.c index f2cb80a..754bece 100644 --- a/java/src/jni/h5pLAPLImp.c +++ b/java/src/jni/h5pLAPLImp.c @@ -134,7 +134,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix H5_LIBRARY_ERROR(ENVONLY); if (NULL == (pre = (char *) HDmalloc(sizeof(char) * (size_t) prefix_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_elink_prefix: memory allocation failed"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_elink_prefix: memory allocation failed"); if (H5Pget_elink_prefix((hid_t)lapl_id, (char *)pre, (size_t) prefix_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -142,7 +142,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, pre))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_elink_prefix: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_elink_prefix: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, prefix, 0, str); diff --git a/java/src/jni/h5plImp.c b/java/src/jni/h5plImp.c index 90d78fe..ce42842 100644 --- a/java/src/jni/h5plImp.c +++ b/java/src/jni/h5plImp.c @@ -129,7 +129,7 @@ done: */ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLreplace - (JNIEnv *env, jclass clss, jobjectArray plugin_path, jint index) + (JNIEnv *env, jclass clss, jobjectArray plugin_path, jint idx) { const char *newPath = NULL; herr_t retVal = FAIL; @@ -139,12 +139,12 @@ Java_hdf_hdf5lib_H5_H5PLreplace if (NULL == plugin_path) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5PLreplace: new path is NULL"); - if (index < 0) + if (idx < 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5PLreplace: index < 0"); PIN_JAVA_STRING(ENVONLY, plugin_path, newPath, NULL, "H5PLreplace: new path not pinned"); - if ((retVal = H5PLreplace(newPath, (unsigned) index)) < 0) + if ((retVal = H5PLreplace(newPath, (unsigned) idx)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -159,7 +159,7 @@ done: */ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLinsert - (JNIEnv *env, jclass clss, jobjectArray plugin_path, jint index) + (JNIEnv *env, jclass clss, jobjectArray plugin_path, jint idx) { const char *newPath = NULL; herr_t retVal = FAIL; @@ -169,12 +169,12 @@ Java_hdf_hdf5lib_H5_H5PLinsert if (NULL == plugin_path) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5PLinsert: new path is NULL"); - if (index < 0) + if (idx < 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5PLinsert: index < 0"); PIN_JAVA_STRING(ENVONLY, plugin_path, newPath, NULL, "H5PLinsert: new path not pinned"); - if ((retVal = H5PLinsert(newPath, (unsigned) index)) < 0) + if ((retVal = H5PLinsert(newPath, (unsigned) idx)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -189,14 +189,14 @@ done: */ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLremove - (JNIEnv *env, jclass clss, jint index) + (JNIEnv *env, jclass clss, jint idx) { UNUSED(clss); - if (index < 0) + if (idx < 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5PLremove: index < 0"); - if (H5PLremove((unsigned) index) < 0) + if (H5PLremove((unsigned) idx) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -210,7 +210,7 @@ done: */ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5PLget - (JNIEnv *env, jclass clss, jint index) + (JNIEnv *env, jclass clss, jint idx) { jstring str = NULL; ssize_t buf_size; @@ -218,17 +218,17 @@ Java_hdf_hdf5lib_H5_H5PLget UNUSED(clss); - if (index < 0) + if (idx < 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5PLget: index < 0"); /* Get the length of the name */ - if ((buf_size = H5PLget((unsigned) index, NULL, 0)) < 0) + if ((buf_size = H5PLget((unsigned) idx, NULL, 0)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5PLget: failed to allocate plugin name buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5PLget: failed to allocate plugin name buffer"); - if ((H5PLget((unsigned) index, aName, (size_t)buf_size + 1)) < 0) + if ((H5PLget((unsigned) idx, aName, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); aName[buf_size] = '\0'; diff --git a/java/src/jni/h5rImp.c b/java/src/jni/h5rImp.c index 1a77fd3..e76fccb 100644 --- a/java/src/jni/h5rImp.c +++ b/java/src/jni/h5rImp.c @@ -59,9 +59,9 @@ Java_hdf_hdf5lib_H5_H5Rcreate } if ((H5R_OBJECT == ref_type) && (refBufLen != H5R_OBJ_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: reference input array length != H5R_OBJ_REF_BUF_SIZE") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: reference input array length != H5R_OBJ_REF_BUF_SIZE"); else if ((H5R_DATASET_REGION == ref_type) && (refBufLen != H5R_DSET_REG_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); else if ((H5R_OBJECT != ref_type) && (H5R_DATASET_REGION != ref_type)) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: unknown reference type"); @@ -106,9 +106,9 @@ Java_hdf_hdf5lib_H5__1H5Rdereference } if ((H5R_OBJECT == ref_type) && (refBufLen != H5R_OBJ_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: reference input array length != H5R_OBJ_REF_BUF_SIZE") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: reference input array length != H5R_OBJ_REF_BUF_SIZE"); else if ((H5R_DATASET_REGION == ref_type) && (refBufLen != H5R_DSET_REG_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); else if ((H5R_OBJECT != ref_type) && (H5R_DATASET_REGION != ref_type)) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: unknown reference type"); @@ -268,16 +268,16 @@ Java_hdf_hdf5lib_H5_H5Rget_1name } if ((H5R_OBJECT == ref_type) && (refBufLen != H5R_OBJ_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: reference input array length != H5R_OBJ_REF_BUF_SIZE") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: reference input array length != H5R_OBJ_REF_BUF_SIZE"); else if ((H5R_DATASET_REGION == ref_type) && (refBufLen != H5R_DSET_REG_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE") + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); else if ((H5R_OBJECT != ref_type) && (H5R_DATASET_REGION != ref_type)) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: unknown reference type"); PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rget_name: reference buffer not pinned"); - if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)size + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Rget_name: failed to allocate referenced object name buffer"); + if (NULL == (aName = HDmalloc(sizeof(char) * (size_t)size + 1))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Rget_name: failed to allocate referenced object name buffer"); if ((ret_val = (jlong)H5Rget_name((hid_t)loc_id, (H5R_type_t)ref_type, refBuf, aName, (size_t)size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); diff --git a/java/src/jni/h5sImp.c b/java/src/jni/h5sImp.c index 3c675b8..8d84314 100644 --- a/java/src/jni/h5sImp.c +++ b/java/src/jni/h5sImp.c @@ -98,7 +98,7 @@ Java_hdf_hdf5lib_H5__1H5Screate_1simple PIN_LONG_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Screate_simple: dims not pinned"); if (NULL == (sa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Screate_simple: failed to allocate dims buffer") + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Screate_simple: failed to allocate dims buffer"); jlp = (jlong *) dimsP; for (i = 0; i < rank; i++) { @@ -115,7 +115,7 @@ Java_hdf_hdf5lib_H5__1H5Screate_1simple PIN_LONG_ARRAY(ENVONLY, maxdims, maxdimsP, &isCopy, "H5Screate_simple: maxdims not pinned"); if (NULL == (msa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Screate_simple: failed to allocate maxdims buffer") + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Screate_simple: failed to allocate maxdims buffer"); jlp = (jlong *) maxdimsP; for (i = 0; i < mrank; i++) { @@ -162,9 +162,10 @@ done: } /* end Java_hdf_hdf5lib_H5__1H5Scopy */ #ifdef notdef -// 10/28/99 -- added code to copy the array -- this is not used, -// but serves as a reminder in case we try to implement this in -// the future.... +/* 10/28/99 -- added code to copy the array -- this is not used, + * but serves as a reminder in case we try to implement this in + * the future.... + */ /* * Note: the argument coord is actually long coord[][], which has been * flattened by the caller. @@ -194,7 +195,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1elements PIN_LONG_ARRAY(ENVONLY, coords, P, &isCopy, "H5Sselect_elements: coords not pinned"); if (NULL == (sa = (hssize_t *) HDmalloc( (size_t)num_elemn * 2 * sizeof(hssize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_elements: failed to allocate coordinate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_elements: failed to allocate coordinate buffer"); for (i = 0; i < (num_elemn * 2); i++) { sa[i] = P[i]; @@ -247,7 +248,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1elements nlongs = (int)((size_t)size / sizeof(jlong)); if (NULL == (lp = (hsize_t *) HDmalloc((size_t)nlongs * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_elements: failed to allocate coordinate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_elements: failed to allocate coordinate buffer"); jlp = (jlong *) P; llp = lp; @@ -444,7 +445,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims } if (NULL == (sa = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_simple_extent_dims: failed to allocate dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_simple_extent_dims: failed to allocate dimension buffer"); } if (NULL == maxdims) { @@ -462,10 +463,10 @@ Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims if (rank < 0) rank = mrank; else if (mrank != rank) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_simple_extent_dims: maxdims rank not same as dims"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_simple_extent_dims: maxdims rank not same as dims"); if (NULL == (msa = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_simple_extent_dims: failed to allocate maximum dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_simple_extent_dims: failed to allocate maximum dimension buffer"); } if ((status = H5Sget_simple_extent_dims(space_id, (hsize_t *)sa, (hsize_t *)msa)) < 0) @@ -564,7 +565,7 @@ Java_hdf_hdf5lib_H5_H5Sset_1extent_1simple PIN_LONG_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Sset_extent_simple: dims not pinned"); if (NULL == (sa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sset_extent_simple: failed to allocate dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sset_extent_simple: failed to allocate dimension buffer"); jlp = (jlong *) dimsP; for (i = 0; i < rank; i++) { @@ -581,7 +582,7 @@ Java_hdf_hdf5lib_H5_H5Sset_1extent_1simple PIN_LONG_ARRAY(ENVONLY, maxdims, maxdimsP, &isCopy, "H5Sset_extent_simple: maxdims not pinned"); if (NULL == (msa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sset_extent_simple: failed to allocate maximum dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sset_extent_simple: failed to allocate maximum dimension buffer"); jlp = (jlong *) maxdimsP; for (i = 0; i < rank; i++) { @@ -660,7 +661,7 @@ Java_hdf_hdf5lib_H5_H5Soffset_1simple rank = (size_t) i / sizeof(jlong); if (NULL == (sa = lp = (hssize_t *) HDmalloc((size_t)rank * sizeof(hssize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Soffset_simple: failed to allocate offset buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Soffset_simple: failed to allocate offset buffer"); jlp = (jlong *) P; for (i = 0; (size_t) i < rank; i++) { @@ -788,7 +789,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab PIN_LONG_ARRAY(ENVONLY, start, startP, &isCopy, "H5Sselect_hyperslab: start not pinned"); if (NULL == (strt = lp = (hsize_t *) HDmalloc((size_t)start_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate start buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate start buffer"); jlp = (jlong *) startP; for (i = 0; i < start_rank; i++) { @@ -800,7 +801,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab PIN_LONG_ARRAY(ENVONLY, count, countP, &isCopy, "H5Sselect_hyperslab: count not pinned"); if (NULL == (cnt = lp = (hsize_t *) HDmalloc((size_t)count_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate count buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate count buffer"); jlp = (jlong *) countP; for (i = 0; i < count_rank; i++) { @@ -825,7 +826,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab PIN_LONG_ARRAY(ENVONLY, stride, strideP, &isCopy, "H5Sselect_hyperslab: stride not pinned"); if (NULL == (strd = lp = (hsize_t *) HDmalloc((size_t)stride_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate stride buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate stride buffer"); jlp = (jlong *) strideP; for (i = 0; i < stride_rank; i++) { @@ -851,7 +852,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab PIN_LONG_ARRAY(ENVONLY, block, blockP, &isCopy, "H5Sselect_hyperslab: block not pinned"); if (NULL == (blk = lp = (hsize_t *) HDmalloc((size_t)block_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate block buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate block buffer"); jlp = (jlong *) blockP; for (i = 0; i < block_rank; i++) { @@ -988,7 +989,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1blocklist buf_size = (size_t) numblocks * (size_t) 2 * (size_t) rank * sizeof(hsize_t); if (NULL == (ba = (hsize_t *) HDmalloc(buf_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_select_hyper_blocklist: failed to allocate block list buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_select_hyper_blocklist: failed to allocate block list buffer"); if ((status = H5Sget_select_hyper_blocklist((hid_t)spaceid, (hsize_t) startblock, (hsize_t) numblocks, (hsize_t *)ba)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1044,7 +1045,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1pointlist PIN_LONG_ARRAY(ENVONLY, buf, bufP, &isCopy, "H5Sget_select_elem_pointlist: buffer not pinned"); if (NULL == (ba = (hsize_t *) HDmalloc(((size_t)numpoints * (size_t)rank) * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_select_elem_pointlist: failed to allocate point list buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_select_elem_pointlist: failed to allocate point list buffer"); if ((status = H5Sget_select_elem_pointlist((hid_t)spaceid, (hsize_t)startpoint, (hsize_t)numpoints, (hsize_t *)ba)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1094,12 +1095,12 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1bounds } if (NULL == (strt = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_select_bounds: failed to allocate start buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_select_bounds: failed to allocate start buffer"); PIN_LONG_ARRAY(ENVONLY, end, endP, &isCopy, "H5Sget_select_bounds: end not pinned"); if (NULL == (en = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_select_bounds: failed to allocate end buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_select_bounds: failed to allocate end buffer"); if ((status = H5Sget_select_bounds((hid_t) spaceid, (hsize_t *) strt, (hsize_t *) en)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1148,7 +1149,7 @@ Java_hdf_hdf5lib_H5_H5Sencode H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sencode: buf_size = 0"); if (NULL == (bufPtr = (unsigned char *) HDcalloc((size_t) 1, buf_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sencode: failed to allocate encoding buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sencode: failed to allocate encoding buffer"); if ((status = H5Sencode((hid_t) obj_id, bufPtr, &buf_size)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1258,7 +1259,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab PIN_LONG_ARRAY(ENVONLY, start, startP, &isCopy, "H5Sget_regular_hyperslab: start not pinned"); if (NULL == (strt = (hsize_t *) HDmalloc((size_t)start_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate start buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate start buffer"); } if (NULL == stride) { @@ -1277,7 +1278,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab PIN_LONG_ARRAY(ENVONLY, stride, strideP, &isCopy, "H5Sget_regular_hyperslab: stride not pinned"); if (NULL == (strd = (hsize_t *) HDmalloc((size_t)stride_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate stride buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate stride buffer"); } if (NULL == count) { @@ -1296,7 +1297,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab PIN_LONG_ARRAY(ENVONLY, count, countP, &isCopy, "H5Sget_regular_hyperslab: count not pinned"); if (NULL == (cnt = (hsize_t *) HDmalloc((size_t)count_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate count buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate count buffer"); } if (NULL == block) { @@ -1315,7 +1316,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab PIN_LONG_ARRAY(ENVONLY, block, blockP, &isCopy, "H5Sget_regular_hyperslab: block not pinned"); if (NULL == (blk = (hsize_t *) HDmalloc((size_t)block_rank * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate block buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate block buffer"); } if ((status = H5Sget_regular_hyperslab(space_id, (hsize_t *) strt, (hsize_t *) strd, (hsize_t *) cnt, (hsize_t *) blk)) < 0) diff --git a/java/src/jni/h5sImp.h b/java/src/jni/h5sImp.h index 141e504..a07d4c5 100644 --- a/java/src/jni/h5sImp.h +++ b/java/src/jni/h5sImp.h @@ -49,9 +49,10 @@ Java_hdf_hdf5lib_H5__1H5Scopy (JNIEnv *, jclass, jlong); #ifdef notdef -// 10/28/99 -- added code to copy the array -- this is not used, -// but serves as a reminder in case we try to implement this in -// the future.... +/* 10/28/99 -- added code to copy the array -- this is not used, + * but serves as a reminder in case we try to implement this in + * the future.... + */ /* * Note: the argument coord is actually long coord[][], which has been * flattened by the caller. diff --git a/java/src/jni/h5tImp.c b/java/src/jni/h5tImp.c index 460f12e..5ef0c3d 100644 --- a/java/src/jni/h5tImp.c +++ b/java/src/jni/h5tImp.c @@ -1210,7 +1210,7 @@ Java_hdf_hdf5lib_H5_H5Tenum_1nameof_1int H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tenum_nameof_int: name size < 0"); if (NULL == (nameP = (char *) HDmalloc(sizeof(char) * (size_t)size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Tenum_nameof_int: failed to allocate name buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tenum_nameof_int: failed to allocate name buffer"); PIN_INT_ARRAY(ENVONLY, value, intP, &isCopy, "H5Tenum_nameof_int: value not pinned"); @@ -1256,7 +1256,7 @@ Java_hdf_hdf5lib_H5_H5Tenum_1nameof H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_nameof: value is NULL"); if (NULL == (nameP = (char *) HDmalloc(sizeof(char) * (size_t)size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Tenum_nameof: failed to allocate name buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tenum_nameof: failed to allocate name buffer"); PIN_BYTE_ARRAY(ENVONLY, value, byteP, &isCopy, "H5Tenum_nameof: value not pinned"); @@ -1456,7 +1456,7 @@ Java_hdf_hdf5lib_H5_H5Tget_1array_1dims } if (NULL == (cdims = (hsize_t *) HDmalloc((size_t)dlen * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Tget_array_dims: failed to allocate dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tget_array_dims: failed to allocate dimension buffer"); if ((ndims = H5Tget_array_dims2((hid_t)type_id, cdims)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1597,10 +1597,10 @@ Java_hdf_hdf5lib_H5__1H5Tarray_1create2 } if (dlen != rank) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Tarray_create: dimension array length != array rank"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tarray_create: dimension array length != array rank"); if (NULL == (cdims = (hsize_t *) HDmalloc((size_t)dlen * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Tarray_create: failed to allocate dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tarray_create: failed to allocate dimension buffer"); for (i = 0; i < (size_t) dlen; i++) { cdims[i] = (hsize_t)dimsP[i]; @@ -1647,7 +1647,7 @@ Java_hdf_hdf5lib_H5_H5Tget_1array_1dims2 } if (NULL == (cdims = (hsize_t *) HDmalloc((size_t)dlen * sizeof(hsize_t)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Tarray_get_dims2: failed to allocate dimension buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tarray_get_dims2: failed to allocate dimension buffer"); if ((ndims = H5Tget_array_dims2((hid_t)type_id, (hsize_t*)cdims)) < 0) H5_LIBRARY_ERROR(ENVONLY); diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index af83caa..e8bfab2 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -71,6 +71,12 @@ static int render_bin_output_region_data_points(FILE *stream, hid_t region_s static int render_bin_output_region_points(FILE *stream, hid_t region_space, hid_t region_id, hid_t container); +/* Strings for output */ +#define H5_TOOLS_GROUP "GROUP" +#define H5_TOOLS_DATASET "DATASET" +#define H5_TOOLS_DATATYPE "DATATYPE" +#define H5_TOOLS_ATTRIBUTE "ATTRIBUTE" + /** frees memory held by array of strings */ void h5str_array_free @@ -217,7 +223,7 @@ h5str_convert switch (typeSize) { case sizeof(float): { - float tmp_float = 0.0; + float tmp_float = 0.0f; sscanf(token, "%f", &tmp_float); HDmemcpy(cptr, &tmp_float, sizeof(float)); @@ -509,7 +515,7 @@ h5str_convert total_elmts *= dims[i]; if (NULL == (cptr = (char *) HDcalloc((size_t)total_elmts, baseTypeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: failed to allocate array buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_convert: failed to allocate array buffer"); for (i = 0; i < total_elmts; i++) { if (!(h5str_convert(ENVONLY, &this_str, container, mtid, out_buf, i * baseTypeSize))) { @@ -550,7 +556,7 @@ h5str_convert H5_LIBRARY_ERROR(ENVONLY); if (NULL == (vl_buf->p = HDmalloc(baseTypeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: failed to allocate vlen buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_convert: failed to allocate vlen buffer"); vl_buf->len = 1; /* Skip whitespace and vlen indicators */ @@ -564,7 +570,7 @@ h5str_convert char *tmp_realloc; if (NULL == (tmp_realloc = (char *) HDrealloc(vl_buf->p, vl_buf->len * 2 * baseTypeSize))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: failed to reallocate vlen buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_convert: failed to reallocate vlen buffer"); vl_buf->len *= 2; vl_buf->p = tmp_realloc; } @@ -640,6 +646,7 @@ h5str_sprintf static char fmt_llong[8], fmt_ullong[8]; H5T_class_t tclass = H5T_NO_CLASS; size_t typeSize = 0; + H5T_sign_t nsign = H5T_SGN_ERROR; hid_t mtid = H5I_INVALID_HID; char *cptr = (char *) in_buf; char *this_str = NULL; @@ -655,13 +662,15 @@ h5str_sprintf H5_LIBRARY_ERROR(ENVONLY); if (!(typeSize = H5Tget_size(tid))) H5_LIBRARY_ERROR(ENVONLY); + if (!(nsign = H5Tget_sign(tid))) + H5_LIBRARY_ERROR(ENVONLY); /* Build default formats for long long types */ if (!fmt_llong[0]) { - if (HDsprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: sprintf failure"); - if (HDsprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: sprintf failure"); + if (HDsnprintf(fmt_llong, sizeof(fmt_llong), "%%%sd", H5_PRINTF_LL_WIDTH) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); + if (HDsnprintf(fmt_ullong, sizeof(fmt_ullong), "%%%su", H5_PRINTF_LL_WIDTH) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } /* end if */ switch (tclass) { @@ -670,12 +679,12 @@ h5str_sprintf switch (typeSize) { case sizeof(float): { - float tmp_float = 0.0; + float tmp_float = 0.0f; HDmemcpy(&tmp_float, cptr, sizeof(float)); if (NULL == (this_str = (char *) HDmalloc(25))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%g", tmp_float) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -690,7 +699,7 @@ h5str_sprintf HDmemcpy(&tmp_double, cptr, sizeof(double)); if (NULL == (this_str = (char *) HDmalloc(25))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%g", tmp_double) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -705,7 +714,7 @@ h5str_sprintf HDmemcpy(&tmp_ldouble, cptr, sizeof(long double)); if (NULL == (this_str = (char *) HDmalloc(27))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%Lf", tmp_ldouble) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -733,7 +742,10 @@ h5str_sprintf H5_LIBRARY_ERROR(ENVONLY); if (is_variable) { - if (NULL != (tmp_str = *(char **) in_buf)) + /* cp_vp is the pointer into the struct where a `char*' is stored. So we have + * to dereference the pointer to get the `char*' to pass to HDstrlen(). */ + tmp_str = *(char **)in_buf; + if (NULL != tmp_str) typeSize = HDstrlen(tmp_str); } else { @@ -743,14 +755,13 @@ h5str_sprintf /* Check for NULL pointer for string */ if (!tmp_str) { if (NULL == (this_str = (char *) HDmalloc(5))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); HDstrncpy(this_str, "NULL", 5); } else { if (typeSize > 0) { if (NULL == (this_str = (char *) HDmalloc(typeSize + 1))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); HDstrncpy(this_str, tmp_str, typeSize); this_str[typeSize] = '\0'; @@ -762,7 +773,6 @@ h5str_sprintf case H5T_INTEGER: { - H5T_sign_t nsign = H5T_SGN_ERROR; if (H5T_SGN_ERROR == (nsign = H5Tget_sign(tid))) H5_LIBRARY_ERROR(ENVONLY); @@ -777,16 +787,16 @@ h5str_sprintf HDmemcpy(&tmp_uchar, cptr, sizeof(unsigned char)); if (NULL == (this_str = (char *) HDmalloc(7))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%u", tmp_uchar) < 0) + if (HDsprintf(this_str, "%hhu", tmp_uchar) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); } else { HDmemcpy(&tmp_char, cptr, sizeof(char)); if (NULL == (this_str = (char *) HDmalloc(7))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%hhd", tmp_char) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -804,18 +814,18 @@ h5str_sprintf HDmemcpy(&tmp_ushort, cptr, sizeof(unsigned short)); if (NULL == (this_str = (char *) HDmalloc(9))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%u", tmp_ushort) < 0) + if (HDsprintf(this_str, "%hu", tmp_ushort) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); } else { HDmemcpy(&tmp_short, cptr, sizeof(short)); if (NULL == (this_str = (char *) HDmalloc(9))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%d", tmp_short) < 0) + if (HDsprintf(this_str, "%hd", tmp_short) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); } @@ -831,7 +841,7 @@ h5str_sprintf HDmemcpy(&tmp_uint, cptr, sizeof(unsigned int)); if (NULL == (this_str = (char *) HDmalloc(14))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%u", tmp_uint) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -840,7 +850,7 @@ h5str_sprintf HDmemcpy(&tmp_int, cptr, sizeof(int)); if (NULL == (this_str = (char *) HDmalloc(14))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%d", tmp_int) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -858,7 +868,7 @@ h5str_sprintf HDmemcpy(&tmp_ulong, cptr, sizeof(unsigned long)); if (NULL == (this_str = (char *) HDmalloc(23))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%lu", tmp_ulong) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -867,7 +877,7 @@ h5str_sprintf HDmemcpy(&tmp_long, cptr, sizeof(long)); if (NULL == (this_str = (char *) HDmalloc(23))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%ld", tmp_long) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -886,7 +896,7 @@ h5str_sprintf HDmemcpy(&tmp_ullong, cptr, sizeof(unsigned long long)); if (NULL == (this_str = (char *) HDmalloc(25))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, fmt_ullong, tmp_ullong) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -895,7 +905,7 @@ h5str_sprintf HDmemcpy(&tmp_llong, cptr, sizeof(long long)); if (NULL == (this_str = (char *) HDmalloc(25))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, fmt_llong, tmp_llong) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -960,7 +970,7 @@ h5str_sprintf size_t i; if (NULL == (this_str = (char *) HDmalloc(4 * (typeSize + 1)))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (1 == typeSize) { if (HDsprintf(this_str, "%#02x", ucptr[0]) < 0) @@ -1173,7 +1183,7 @@ h5str_sprintf /* All other types get printed as hexadecimal */ if (NULL == (this_str = (char *) HDmalloc(4 * (typeSize + 1)))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (1 == typeSize) { if (HDsprintf(this_str, "%#02x", ucptr[0]) < 0) @@ -1246,7 +1256,7 @@ h5str_print_region_data_blocks /* Allocate space for the dimension array */ if (NULL == (dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate dimension array buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate dimension array buffer"); /* Find the dimensions of each data space from the block coordinates */ for (jndx = 0, numelem = 1; jndx < (size_t) ndims; jndx++) { @@ -1262,15 +1272,15 @@ h5str_print_region_data_blocks H5_LIBRARY_ERROR(ENVONLY); if (NULL == (region_buf = HDmalloc(type_size * (size_t)numelem))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate region buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate region buffer"); /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ /* 1 2 n 1 2 n */ if (NULL == (start = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate hyperslab start buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate hyperslab start buffer"); if (NULL == (count = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate hyperslab count buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate hyperslab count buffer"); for (blkndx = 0; blkndx < (hsize_t) nblocks; blkndx++) { for (indx = 0; indx < (unsigned) ndims; indx++) { @@ -1345,7 +1355,7 @@ h5str_dump_region_blocks_data alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); if (alloc_size == (hsize_t)((size_t) alloc_size)) { if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks_data: failed to allocate region block buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_region_blocks_data: failed to allocate region block buffer"); if (H5Sget_select_hyper_blocklist(region, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1405,7 +1415,7 @@ h5str_dump_region_blocks int i; if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks: failed to allocate region block buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_region_blocks: failed to allocate region block buffer"); if (H5Sget_select_hyper_blocklist(region, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1490,7 +1500,7 @@ h5str_print_region_data_points /* Allocate space for the dimension array */ if (NULL == (dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_points: failed to allocate dimension array buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_points: failed to allocate dimension array buffer"); dims1[0] = (hsize_t)npoints; @@ -1502,7 +1512,7 @@ h5str_print_region_data_points H5_LIBRARY_ERROR(ENVONLY); if (NULL == (region_buf = HDmalloc(type_size * (size_t)npoints))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_points: failed to allocate region buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_points: failed to allocate region buffer"); if (H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1562,7 +1572,7 @@ h5str_dump_region_points_data alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); if (alloc_size == (hsize_t)((size_t) alloc_size)) { if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_points_data: failed to allocate region point data buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_region_points_data: failed to allocate region point data buffer"); if (H5Sget_select_elem_pointlist(region, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1625,7 +1635,7 @@ h5str_dump_region_points alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); if (alloc_size == (hsize_t)((size_t) alloc_size)) { if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_points: failed to allocate region point buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_region_points: failed to allocate region point buffer"); if (H5Sget_select_elem_pointlist(region, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -2731,7 +2741,7 @@ h5str_dump_simple_dset if (sm_nbytes > 0) { if (NULL == (sm_buf = (unsigned char *) HDmalloc((size_t)sm_nbytes))) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_simple_dset: failed to allocate sm_buf"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_simple_dset: failed to allocate sm_buf"); sm_nelmts = sm_nbytes / p_type_nbytes; @@ -2862,7 +2872,7 @@ h5tools_dump_simple_data h5str_new(&buffer, 32 * size); if (!buffer.s) - H5_JNI_FATAL_ERROR(ENVONLY, "h5tools_dump_simple_data: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5tools_dump_simple_data: failed to allocate buffer"); if (!(bytes_in = h5str_sprintf(ENVONLY, &buffer, container, type, memref, 0, 1))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -2933,7 +2943,7 @@ Java_hdf_hdf5lib_H5_H5AreadComplex } if (NULL == (readBuf = (char *) HDmalloc((size_t)n * size))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadComplex: failed to allocate read buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadComplex: failed to allocate read buffer"); if ((status = H5Aread(attr_id, mem_type_id, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -2941,7 +2951,7 @@ Java_hdf_hdf5lib_H5_H5AreadComplex h5str_new(&h5str, 4 * size); if (!h5str.s) - H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadComplex: failed to allocate string buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadComplex: failed to allocate string buffer"); for (i = 0; i < (size_t) n; i++) { h5str.s[0] = '\0'; @@ -3002,7 +3012,7 @@ Java_hdf_hdf5lib_H5_H5Acopy total_size = (hsize_t)npoints * (hsize_t)type_size; if (NULL == (buf = (jbyte *) HDmalloc((size_t)total_size * sizeof(jbyte)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Acopy: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Acopy: failed to allocate buffer"); if ((retVal = H5Aread((hid_t)src_id, tid, buf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -3049,7 +3059,7 @@ Java_hdf_hdf5lib_H5_H5Dcopy UNUSED(clss); if (!(total_allocated_size = H5Dget_storage_size((hid_t)src_id))) - return 0; // nothing to write + return 0; /* nothing to write */ if ((sid = H5Dget_space((hid_t)src_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -3064,7 +3074,7 @@ Java_hdf_hdf5lib_H5_H5Dcopy total_size = (hsize_t)npoints * (hsize_t)type_size; if (NULL == (buf = (jbyte *) HDmalloc((size_t)total_size * sizeof(jbyte)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Dcopy: failed to allocate buffer"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dcopy: failed to allocate buffer"); if ((retVal = H5Dread((hid_t)src_id, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -3091,15 +3101,15 @@ done: } /* end Java_hdf_hdf5lib_H5_H5Dcopy */ /* -///////////////////////////////////////////////////////////////////////////////// -// -// -// Add these methods so that we don't need to call H5Gget_objtype_by_idx -// in a loop to get information for all the objects in a group, which takes -// a lot of time to finish if the number of objects is more than 10,000 -// -///////////////////////////////////////////////////////////////////////////////// -*/ + * ///////////////////////////////////////////////////////////////////////////////// + * // + * // + * // Add these methods so that we don't need to call H5Gget_objtype_by_idx + * // in a loop to get information for all the objects in a group, which takes + * // a lot of time to finish if the number of objects is more than 10,000 + * // + * ///////////////////////////////////////////////////////////////////////////////// + */ #ifdef __cplusplus herr_t obj_info_all(hid_t g_id, const char *name, const H5L_info_t *linfo, void *op_data); @@ -3174,13 +3184,13 @@ Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full PIN_LONG_ARRAY(ENVONLY, fNo, fnoP, &isCopy, "H5Gget_obj_info_full: fNo not pinned"); if (NULL == (oName = (char **) HDcalloc((size_t)n, sizeof(*oName)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for object name"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for object name"); if (NULL == (refs = (unsigned long *) HDcalloc((size_t)n, sizeof(unsigned long)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for ref. info"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for ref. info"); if (NULL == (fnos = (unsigned long *) HDcalloc((size_t)n, sizeof(unsigned long)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for file number info"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for file number info"); if (group_name) { PIN_JAVA_STRING(ENVONLY, group_name, gName, &isCopy, "H5Gget_obj_info_full: group_name not pinned"); @@ -3269,10 +3279,10 @@ Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max PIN_LONG_ARRAY(ENVONLY, oRef, refP, &isCopy, "H5Gget_obj_info_max: oRef not pinned"); if (NULL == (oName = (char **) HDcalloc((size_t)n, sizeof(*oName)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_max: failed to allocate buffer for object name"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_max: failed to allocate buffer for object name"); if (NULL == (refs = (unsigned long *) HDcalloc((size_t)n, sizeof(unsigned long)))) - H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_max: failed to allocate buffer for ref. info"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_max: failed to allocate buffer for ref. info"); if ((ret_val = H5Gget_obj_info_max((hid_t)loc_id, oName, (int *)otarr, (int *)ltarr, refs, maxnum)) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_max: retrieval of object info failed"); diff --git a/java/src/jni/nativeData.c b/java/src/jni/nativeData.c index 947f843..3c3d3d5 100644 --- a/java/src/jni/nativeData.c +++ b/java/src/jni/nativeData.c @@ -101,7 +101,7 @@ JNIEXPORT jfloatArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ { - jfloatArray rarray; + jfloatArray rarray = NULL; jboolean bb; jfloat *farray = NULL; jfloat *iap = NULL; @@ -152,7 +152,7 @@ JNIEXPORT jshortArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ { - jshortArray rarray; + jshortArray rarray = NULL; jboolean bb; jshort *sarray = NULL; jshort *iap = NULL; @@ -203,7 +203,7 @@ JNIEXPORT jlongArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ { - jlongArray rarray; + jlongArray rarray = NULL; jboolean bb; jlong *larray = NULL; jlong *iap = NULL; @@ -254,7 +254,7 @@ JNIEXPORT jdoubleArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ { - jdoubleArray rarray; + jdoubleArray rarray = NULL; jboolean bb; jdouble *darray = NULL; jdouble *iap = NULL; @@ -305,7 +305,7 @@ JNIEXPORT jintArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ { - jintArray rarray; + jintArray rarray = NULL; jboolean bb; jint *iarray = NULL; jint *iap = NULL; @@ -327,7 +327,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B } if ((start < 0) || ((int)(start + (len * (int)sizeof(jint))) > blen)) - H5_JNI_FATAL_ERROR(ENVONLY, "byteToInt: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToInt: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; @@ -357,7 +357,7 @@ JNIEXPORT jshortArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ { - jshortArray rarray; + jshortArray rarray = NULL; jboolean bb; jshort *sarray = NULL; jshort *iap = NULL; @@ -379,7 +379,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B } if ((start < 0) || ((int)(start + (len * (int)sizeof(jshort))) > blen)) - H5_JNI_FATAL_ERROR(ENVONLY, "byteToShort: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToShort: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; @@ -409,7 +409,7 @@ JNIEXPORT jfloatArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ { - jfloatArray rarray; + jfloatArray rarray = NULL; jboolean bb; jfloat *farray = NULL; jfloat *iap = NULL; @@ -431,7 +431,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B } if ((start < 0) || ((int)(start + (len * (int)sizeof(jfloat))) > blen)) - H5_JNI_FATAL_ERROR(ENVONLY, "byteToFloat: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToFloat: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; @@ -461,7 +461,7 @@ JNIEXPORT jlongArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ { - jlongArray rarray; + jlongArray rarray = NULL; jboolean bb; jlong *larray = NULL; jlong *iap = NULL; @@ -483,7 +483,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B } if ((start < 0) || ((int)(start + (len * (int)sizeof(jlong))) > blen)) - H5_JNI_FATAL_ERROR(ENVONLY, "byteToLong: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToLong: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; @@ -513,7 +513,7 @@ JNIEXPORT jdoubleArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ { - jdoubleArray rarray; + jdoubleArray rarray = NULL; jboolean bb; jdouble *darray = NULL; jdouble *iap = NULL; @@ -535,7 +535,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B } if ((start < 0) || ((int)(start + (len * (int)sizeof(jdouble))) > blen)) - H5_JNI_FATAL_ERROR(ENVONLY, "byteToDouble: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToDouble: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; @@ -565,7 +565,7 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I (JNIEnv *env, jclass clss, jint start, jint len, jintArray idata) /* IN: array of int */ { - jbyteArray rarray; + jbyteArray rarray = NULL; jboolean bb; jbyte *barray = NULL; jbyte *bap = NULL; @@ -593,7 +593,7 @@ Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I } if ((start < 0) || (((start + len)) > ilen)) - H5_JNI_FATAL_ERROR(ENVONLY, "intToByte: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "intToByte: start < 0 or len exceeded buffer length"); ip = iarr + start; @@ -627,7 +627,7 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S (JNIEnv *env, jclass clss, jint start, jint len, jshortArray sdata) /* IN: array of short */ { - jbyteArray rarray; + jbyteArray rarray = NULL; jboolean bb; jshort *ip = NULL; jshort *sarr = NULL; @@ -655,7 +655,7 @@ Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S } if ((start < 0) || (((start + len)) > ilen)) - H5_JNI_FATAL_ERROR(ENVONLY, "shortToByte: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "shortToByte: start < 0 or len exceeded buffer length"); ip = sarr + start; @@ -689,7 +689,7 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F (JNIEnv *env, jclass clss, jint start, jint len, jfloatArray fdata) /* IN: array of float */ { - jbyteArray rarray; + jbyteArray rarray = NULL; jboolean bb; jfloat *ip = NULL; jfloat *farr = NULL; @@ -717,7 +717,7 @@ Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F } if ((start < 0) || (((start + len)) > ilen)) - H5_JNI_FATAL_ERROR(ENVONLY, "floatToByte: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "floatToByte: start < 0 or len exceeded buffer length"); ip = farr + start; @@ -751,7 +751,7 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D (JNIEnv *env, jclass clss, jint start, jint len, jdoubleArray ddata) /* IN: array of double */ { - jbyteArray rarray; + jbyteArray rarray = NULL; jboolean bb; jdouble *ip = NULL; jdouble *darr = NULL; @@ -779,7 +779,7 @@ Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D } if ((start < 0) || (((start + len)) > ilen)) - H5_JNI_FATAL_ERROR(ENVONLY, "doubleToByte: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "doubleToByte: start < 0 or len exceeded buffer length"); ip = darr + start; @@ -813,7 +813,7 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J (JNIEnv *env, jclass clss, jint start, jint len, jlongArray ldata) /* IN: array of long */ { - jbyteArray rarray; + jbyteArray rarray = NULL; jboolean bb; jlong *ip = NULL; jlong *larr = NULL; @@ -841,7 +841,7 @@ Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J } if ((start < 0) || (((start + len)) > ilen)) - H5_JNI_FATAL_ERROR(ENVONLY, "longToByte: start < 0 or len exceeded buffer length"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "longToByte: start < 0 or len exceeded buffer length"); ip = larr + start; @@ -875,7 +875,7 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_intToByte__I (JNIEnv *env, jclass clss, jint idata) /* IN: int */ { - jbyteArray rarray; + jbyteArray rarray = NULL; jboolean bb; jbyte *barray = NULL; jbyte *bap = NULL; @@ -911,7 +911,7 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_floatToByte__F (JNIEnv *env, jclass clss, jfloat fdata) /* IN: float */ { - jbyteArray rarray; + jbyteArray rarray = NULL; jboolean bb; jbyte *barray = NULL; jbyte *bap = NULL; @@ -947,7 +947,7 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_shortToByte__S (JNIEnv *env, jclass clss, jshort sdata) /* IN: short */ { - jbyteArray rarray; + jbyteArray rarray = NULL; jboolean bb; jbyte *barray = NULL; jbyte *bap = NULL; @@ -983,7 +983,7 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_doubleToByte__D (JNIEnv *env, jclass clss, jdouble ddata) /* IN: double */ { - jbyteArray rarray; + jbyteArray rarray = NULL; jboolean bb; jbyte *barray = NULL; jbyte *bap = NULL; @@ -1019,7 +1019,7 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_longToByte__J (JNIEnv *env, jclass clss, jlong ldata) /* IN: long */ { - jbyteArray rarray; + jbyteArray rarray = NULL; jboolean bb; jbyte *barray = NULL; jbyte *bap = NULL; @@ -1055,7 +1055,7 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToByte__B (JNIEnv *env, jclass clss, jbyte bdata) /* IN: byte */ { - jbyteArray rarray; + jbyteArray rarray = NULL; jboolean bb; jbyte *barray = NULL; jbyte *bap = NULL; |