diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2016-08-22 17:05:00 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2016-08-22 17:05:00 (GMT) |
commit | 737bb567355940ec0938ab0bacc0eb18ad4201c7 (patch) | |
tree | 1aefa9bd84a886997773107314cc8d0c4c2a10c0 /java/src/jni/h5jni.h | |
parent | f14e4b3e2061c8fb714413473a65d9d61328b8b7 (diff) | |
download | hdf5-737bb567355940ec0938ab0bacc0eb18ad4201c7.zip hdf5-737bb567355940ec0938ab0bacc0eb18ad4201c7.tar.gz hdf5-737bb567355940ec0938ab0bacc0eb18ad4201c7.tar.bz2 |
[svn-r30313] HDFFV-9972: unsatisfied link error under debug on Windows.
Added windows name suffix for debug to CMake cmd_arg for examples and test.
Fix issues discovered under debug testing;
Create a version of H5Iget_name that correctly returns the name.
Rework PIN_JAVA_STRING macro and usage to eliminate possible memory leaks by using if-else instead of mid-routine return.
Update example to use new H5Iget_name API.
Tested: windows under debug
Diffstat (limited to 'java/src/jni/h5jni.h')
-rw-r--r-- | java/src/jni/h5jni.h | 162 |
1 files changed, 49 insertions, 113 deletions
diff --git a/java/src/jni/h5jni.h b/java/src/jni/h5jni.h index da49eeb..9414d31 100644 --- a/java/src/jni/h5jni.h +++ b/java/src/jni/h5jni.h @@ -67,29 +67,17 @@ /* Macros for string access */ -#define PIN_JAVA_STRING(javastr,localstr,retdefault) { \ +#define PIN_JAVA_STRING(javastr,localstr) { \ jboolean isCopy; \ + (localstr) = NULL; \ if ((javastr) == NULL) { \ h5nullArgument(env, "java string is NULL"); \ - return (retdefault); \ } \ - (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ - if ((localstr) == NULL) { \ - h5JNIFatalError(env, "local c string is not pinned"); \ - return (retdefault); \ - } \ -} - -#define PIN_JAVA_STRING0(javastr,localstr) { \ - jboolean isCopy; \ - if ((javastr) == NULL) { \ - h5nullArgument(env, "java string is NULL"); \ - return; \ - } \ - (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ - if ((localstr) == NULL) { \ - h5JNIFatalError(env, "local c string is not pinned"); \ - return; \ + else { \ + (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ + if ((localstr) == NULL) { \ + h5JNIFatalError(env, "local c string is not pinned"); \ + } \ } \ } @@ -97,49 +85,28 @@ ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ } -#define PIN_JAVA_STRING_TWO(javastr,localstr,java2str,local2str,retdefault) { \ +#define PIN_JAVA_STRING_TWO(javastr,localstr,java2str,local2str) { \ jboolean isCopy; \ + (localstr) = NULL; \ + (local2str) = NULL; \ if ((javastr) == NULL) { \ h5nullArgument(env, "java string is NULL"); \ - return (retdefault); \ } \ - if ((java2str) == NULL) { \ + else if ((java2str) == NULL) { \ h5nullArgument(env, "second java string is NULL"); \ - return (retdefault); \ } \ - (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ - if ((localstr) == NULL) { \ - h5JNIFatalError(env, "local c string is not pinned"); \ - return (retdefault); \ - } \ - (local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \ - if ((local2str) == NULL) { \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ - h5JNIFatalError(env, "second local c string is not pinned"); \ - return (retdefault); \ - } \ -} - -#define PIN_JAVA_STRING_TWO0(javastr,localstr,java2str,local2str) { \ - jboolean isCopy; \ - if ((javastr) == NULL) { \ - h5nullArgument(env, "java string is NULL"); \ - return; \ - } \ - if ((java2str) == NULL) { \ - h5nullArgument(env, "second java string is NULL"); \ - return; \ - } \ - (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ - if ((localstr) == NULL) { \ - h5JNIFatalError(env, "local c string is not pinned"); \ - return; \ - } \ - (local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \ - if ((local2str) == NULL) { \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ - h5JNIFatalError(env, "second local c string is not pinned"); \ - return; \ + else { \ + (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ + if ((localstr) == NULL) { \ + h5JNIFatalError(env, "local c string is not pinned"); \ + } \ + else { \ + (local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \ + if ((local2str) == NULL) { \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ + h5JNIFatalError(env, "second local c string is not pinned"); \ + } \ + } \ } \ } @@ -148,71 +115,40 @@ ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \ } -#define PIN_JAVA_STRING_THREE(javastr,localstr,java2str,local2str,java3str,local3str,retdefault) { \ - jboolean isCopy; \ - if ((javastr) == NULL) { \ - h5nullArgument(env, "java string is NULL"); \ - return (retdefault); \ - } \ - if ((java2str) == NULL) { \ - h5nullArgument(env, "second java string is NULL"); \ - return (retdefault); \ - } \ - if ((java3str) == NULL) { \ - h5nullArgument(env, "third java string is NULL"); \ - return (retdefault); \ - } \ - (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ - if ((localstr) == NULL) { \ - h5JNIFatalError(env, "local c string is not pinned"); \ - return (retdefault); \ - } \ - (local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \ - if ((local2str) == NULL) { \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ - h5JNIFatalError(env, "second local c string is not pinned"); \ - return (retdefault); \ - } \ - (local3str) = ENVPTR->GetStringUTFChars(ENVPAR (java3str), &isCopy); \ - if ((local3str) == NULL) { \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \ - h5JNIFatalError(env, "third local c string is not pinned"); \ - return (retdefault); \ - } \ -} - -#define PIN_JAVA_STRING_THREE0(javastr,localstr,java2str,local2str,java3str,local3str) { \ +#define PIN_JAVA_STRING_THREE(javastr,localstr,java2str,local2str,java3str,local3str) { \ jboolean isCopy; \ + (localstr) = NULL; \ + (local2str) = NULL; \ + (local3str) = NULL; \ if ((javastr) == NULL) { \ h5nullArgument(env, "java string is NULL"); \ - return; \ } \ - if ((java2str) == NULL) { \ + else if ((java2str) == NULL) { \ h5nullArgument(env, "second java string is NULL"); \ - return; \ } \ - if ((java3str) == NULL) { \ + else if ((java3str) == NULL) { \ h5nullArgument(env, "third java string is NULL"); \ - return; \ - } \ - (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ - if ((localstr) == NULL) { \ - h5JNIFatalError(env, "local c string is not pinned"); \ - return; \ - } \ - (local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \ - if ((local2str) == NULL) { \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ - h5JNIFatalError(env, "second local c string is not pinned"); \ - return; \ } \ - (local3str) = ENVPTR->GetStringUTFChars(ENVPAR (java3str), &isCopy); \ - if ((local3str) == NULL) { \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \ - h5JNIFatalError(env, "third local c string is not pinned"); \ - return; \ + else { \ + (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ + if ((localstr) == NULL) { \ + h5JNIFatalError(env, "local c string is not pinned"); \ + } \ + else { \ + (local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \ + if ((local2str) == NULL) { \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ + h5JNIFatalError(env, "second local c string is not pinned"); \ + } \ + else { \ + (local3str) = ENVPTR->GetStringUTFChars(ENVPAR (java3str), &isCopy); \ + if ((local3str) == NULL) { \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \ + h5JNIFatalError(env, "third local c string is not pinned"); \ + } \ + } \ + } \ } \ } |