5151#include <stdlib.h>
5252#include <stdbool.h>
5353#include <errno.h>
54+ #include <stdint.h>
5455
5556#ifndef NDEBUG
5657#include <android/log.h>
@@ -85,6 +86,27 @@ JNIEXPORT void JNICALL Java_com_jme3_util_AndroidNativeBufferAllocator_releaseDi
8586 LOG (ANDROID_LOG_INFO , "Buffer mem_address formatted (mem_address, size) -> (%p, %u)" , buffer , sizeof (buffer ));
8687}
8788
89+ JNIEXPORT void JNICALL Java_com_jme3_util_AndroidNativeBufferAllocator_releaseDirectByteBufferAddress
90+ (JNIEnv * env , jobject object , jlong address )
91+ {
92+ (void )env ;
93+ (void )object ;
94+ void * buffer = (void * )(uintptr_t ) address ;
95+ free (buffer );
96+ LOG (ANDROID_LOG_INFO , "Buffer released by address (mem_address) -> (%p)" , buffer );
97+ }
98+
99+ JNIEXPORT jlong JNICALL Java_com_jme3_util_AndroidNativeBufferAllocator_directBufferAddress
100+ (JNIEnv * env , jobject object , jobject bufferObject )
101+ {
102+ (void )object ;
103+ if (bufferObject == NULL ) {
104+ return 0 ;
105+ }
106+ void * buffer = (* env )-> GetDirectBufferAddress (env , bufferObject );
107+ return (jlong )(uintptr_t ) buffer ;
108+ }
109+
88110JNIEXPORT jobject JNICALL Java_com_jme3_util_AndroidNativeBufferAllocator_createDirectByteBuffer
89111(JNIEnv * env , jobject object , jlong size )
90112{
@@ -96,4 +118,4 @@ JNIEXPORT jobject JNICALL Java_com_jme3_util_AndroidNativeBufferAllocator_create
96118 LOG (ANDROID_LOG_INFO , "Buffer created successfully (mem_address, size) -> (%p %lli)" , buffer , size );
97119 }
98120 return (* env )-> NewDirectByteBuffer (env , buffer , size );
99- }
121+ }
0 commit comments