summaryrefslogtreecommitdiffstats
path: root/src/newt/native/NewtCommon.c
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-10-29 13:46:43 +0200
committerSven Gothel <[email protected]>2010-10-29 13:46:43 +0200
commit81ee164ec139337254ef0e8938c19119908de6ae (patch)
treeba0141b67713f4f1e5bd7c89ebf9013484c70af9 /src/newt/native/NewtCommon.c
parent8e1e785f26ff57b58fe6218f7ad1c9379760d367 (diff)
Fix ScreenMode ; Add FatalError to NewtCommon.c ; Fix Windows Build
Fix ScreenMode - Avoid NPE/Out-of-memory: Return zero sized NewIntArrays instead of NULL. Fix Windows Build - ScreenMode still has a regression
Diffstat (limited to 'src/newt/native/NewtCommon.c')
-rw-r--r--src/newt/native/NewtCommon.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/newt/native/NewtCommon.c b/src/newt/native/NewtCommon.c
index 353dcb46f..0e3f99282 100644
--- a/src/newt/native/NewtCommon.c
+++ b/src/newt/native/NewtCommon.c
@@ -4,16 +4,41 @@
static const char * const ClazzNameRuntimeException = "java/lang/RuntimeException";
static jclass runtimeExceptionClz=NULL;
+void NewtCommon_FatalError(JNIEnv *env, const char* msg, ...)
+{
+ char buffer[512];
+ va_list ap;
+
+ va_start(ap, msg);
+ vsnprintf(buffer, sizeof(buffer), msg, ap);
+ va_end(ap);
+
+ fprintf(stderr, "%s\n", buffer);
+ (*env)->FatalError(env, buffer);
+}
+
+void NewtCommon_throwNewRuntimeException(JNIEnv *env, const char* msg, ...)
+{
+ char buffer[512];
+ va_list ap;
+
+ va_start(ap, msg);
+ vsnprintf(buffer, sizeof(buffer), msg, ap);
+ va_end(ap);
+
+ (*env)->ThrowNew(env, runtimeExceptionClz, buffer);
+}
+
void NewtCommon_init(JNIEnv *env) {
if(NULL==runtimeExceptionClz) {
jclass c = (*env)->FindClass(env, ClazzNameRuntimeException);
if(NULL==c) {
- _FatalError(env, "NEWT X11Window: can't find %s", ClazzNameRuntimeException);
+ NewtCommon_FatalError(env, "NEWT X11Window: can't find %s", ClazzNameRuntimeException);
}
runtimeExceptionClz = (jclass)(*env)->NewGlobalRef(env, c);
(*env)->DeleteLocalRef(env, c);
if(NULL==runtimeExceptionClz) {
- _FatalError(env, "NEWT X11Window: can't use %s", ClazzNameRuntimeException);
+ NewtCommon_FatalError(env, "NEWT X11Window: can't use %s", ClazzNameRuntimeException);
}
}
}
@@ -28,15 +53,3 @@ jchar* NewtCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str)
return strChars;
}
-void NewtCommon_throwNewRuntimeException(JNIEnv *env, const char* msg, ...)
-{
- char buffer[512];
- va_list ap;
-
- va_start(ap, msg);
- vsnprintf(buffer, sizeof(buffer), msg, ap);
- va_end(ap);
-
- (*env)->ThrowNew(env, runtimeExceptionClz, buffer);
-}
-