Skip to content

Instantly share code, notes, and snippets.

@junr03
Last active January 8, 2020 01:09
Show Gist options
  • Save junr03/2b6703bb534d60f8e531344ee18c229b to your computer and use it in GitHub Desktop.
Save junr03/2b6703bb534d60f8e531344ee18c229b to your computer and use it in GitHub Desktop.
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