Last active
January 8, 2020 01:09
-
-
Save junr03/2b6703bb534d60f8e531344ee18c229b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static envoy_data buffer_to_native_data(JNIEnv* env, jobject data) { | |
// keep reference in the JNI. | |
jobject j_data = env->NewGlobalRef(data); | |
envoy_data native_data; | |
native_data.bytes = static_cast<uint8_t*>(env->GetDirectBufferAddress(j_data)); | |
native_data.length = env->GetDirectBufferCapacity(j_data); | |
// releasing function and context that Envoy can trigger. | |
native_data.release = jni_delete_global_ref; | |
native_data.context = j_data; | |
return native_data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment