From 7bf7a7e4158df882028df510e8d76009f2640d96 Mon Sep 17 00:00:00 2001 From: ylecollen Date: Mon, 9 Jan 2017 13:55:58 +0100 Subject: use the same way to name the creation method i.e. createNewXX. Avoid the initWithXX. --- .../OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp | 36 ++++++---------------- 1 file changed, 10 insertions(+), 26 deletions(-) (limited to 'java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp') diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp index d1459ae..6e26071 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp +++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp @@ -48,7 +48,16 @@ JNIEXPORT jlong OLM_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv *env, jobject t LOGD("## createNewSessionJni(): IN"); OlmSession* accountPtr = initializeSessionMemory(); - LOGD(" ## createNewSessionJni(): success - accountPtr=%p (jlong)(intptr_t)accountPtr=%lld",accountPtr,(jlong)(intptr_t)accountPtr); + if (!accountPtr) + { + LOGE("## initNewAccount(): failure - init session OOM"); + env->ThrowNew(env->FindClass("java/lang/Exception"), "init session OOM"); + } + else + { + LOGD(" ## createNewSessionJni(): success - accountPtr=%p (jlong)(intptr_t)accountPtr=%lld",accountPtr,(jlong)(intptr_t)accountPtr); + } + return (jlong)(intptr_t)accountPtr; } @@ -70,31 +79,6 @@ JNIEXPORT void OLM_SESSION_FUNC_DEF(releaseSessionJni)(JNIEnv *env, jobject thiz } } -/** -* Initialize a new session and return it to JAVA side.
-* Since a C prt is returned as a jlong, special care will be taken -* to make the cast (OlmSession* => jlong) platform independent. -* @return the initialized OlmSession* instance if init succeed, NULL otherwise -**/ -JNIEXPORT jlong OLM_SESSION_FUNC_DEF(initNewSessionJni)(JNIEnv *env, jobject thiz) -{ - LOGD("## initNewSessionJni(): OlmSession IN"); - - OlmSession* sessionPtr = initializeSessionMemory(); - - // init account memory allocation - if (!sessionPtr) - { - LOGE(" ## initNewSessionJni(): failure - init session OOM"); - } - else - { - LOGD(" ## initNewSessionJni(): success - OLM session created"); - } - - return (jlong)(intptr_t)sessionPtr; -} - // ********************************************************************* // ********************** OUTBOUND SESSION ***************************** // ********************************************************************* -- cgit v1.2.3