shorts
= (*android_java_env)->GetShortArrayElements (android_java_env, array,
NULL);
+ android_exception_check_nonnull (shorts, array);
+
for (i = 1; i < nelements; ++i)
children[i] = shorts[i];
= (*android_java_env)->GetIntArrayElements (android_java_env,
window_geometry,
NULL);
+ android_exception_check_nonnull (ints, window_geometry);
*x_return = ints[0];
*y_return = ints[1];
/* Obtain the coordinates from the array. */
ints = (*android_java_env)->GetIntArrayElements (android_java_env,
coordinates, NULL);
- android_exception_check_1 (coordinates);
+ android_exception_check_nonnull (ints, coordinates);
*root_x = ints[0];
*root_y = ints[1];
}
}
+/* Check for JNI problems based on the value of OBJECT.
+
+ Signal out of memory if OBJECT is NULL. OBJECT1 means the
+ same as in `android_exception_check_1'.
+
+ This function is useful when checking for errors from JNI
+ functions that do not set exceptions on failure, such as
+ `GetIntArrayElements'. */
+
+void
+android_exception_check_nonnull (void *object, jobject object1)
+{
+ if (object)
+ return;
+
+ if (object1)
+ ANDROID_DELETE_LOCAL_REF (object1);
+
+ memory_full (0);
+}
\f
longs = (*android_java_env)->GetLongArrayElements (android_java_env,
array, NULL);
- android_exception_check_1 (array);
+ android_exception_check_nonnull (longs, array);
status->capacity = longs[0];
status->charge_counter = longs[1];
extern void android_exception_check (void);
extern void android_exception_check_1 (jobject);
extern void android_exception_check_2 (jobject, jobject);
+extern void android_exception_check_nonnull (void *, jobject);
extern void android_get_keysym_name (int, char *, size_t);
extern void android_wait_event (void);
bytes);
data = (*android_java_env)->GetByteArrayElements (android_java_env,
bytes, NULL);
- android_exception_check_1 (bytes);
+ android_exception_check_nonnull (data, bytes);
string = make_unibyte_string ((char *) data, length);