From b85c779595d679a3d24de37751b27fe70e878149 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Tue, 23 Sep 2014 14:16:41 +0200 Subject: android: use JNI direct memory allocator from Fennec Change-Id: I95a9ab54222150a1f9cde30df820f3cd6915f641 --- desktop/source/lib/lokandroid.cxx | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx index bc9a8b0b1274..6a0ba2a41648 100644 --- a/desktop/source/lib/lokandroid.cxx +++ b/desktop/source/lib/lokandroid.cxx @@ -80,6 +80,7 @@ extern "C" SAL_JNI_EXPORT jlong JNICALL Java_org_libreoffice_kit_Office_document } /* Document */ + extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_destroy (JNIEnv* pEnv, jobject aObject) { @@ -164,7 +165,8 @@ extern "C" SAL_JNI_EXPORT jlong JNICALL Java_org_libreoffice_kit_Document_getDoc return nWidth; } -extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Office_saveAs(JNIEnv* pEnv, jobject aObject, jstring sUrl, jstring sFormat, jstring sOptions) +extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Office_saveAs + (JNIEnv* pEnv, jobject aObject, jstring sUrl, jstring sFormat, jstring sOptions) { LibreOfficeKitDocument* pDocument = getHandle(pEnv, aObject); @@ -181,4 +183,28 @@ extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Office_saveAs(JN return result; } +/* DirectBufferAllocator */ + +extern "C" SAL_JNI_EXPORT jobject JNICALL Java_org_libreoffice_kit_DirectBufferAllocator_allocateDirectBufferNative + (JNIEnv* pEnv, jclass /*aClass*/, jlong nSize) +{ + jobject aBuffer = NULL; + void* pMemory = malloc(nSize); + if (pMemory != NULL) + { + aBuffer = pEnv->NewDirectByteBuffer(pMemory, nSize); + if (!aBuffer) + { + free(pMemory); + } + } + return aBuffer; +} + +extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_DirectBufferAllocator_freeDirectBufferNative + (JNIEnv* pEnv, jclass, jobject aBuffer) +{ + free(pEnv->GetDirectBufferAddress(aBuffer)); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit