🗒️
notes
  • Journal
  • URLs
  • Java Card
    • SCP02
    • Rapid Notes
    • _FIXVALS_
    • Mifare
    • Chain Of Trust
  • Encoding
    • CBEFF
    • Bytes
  • Snippets
    • JNI_OnLoad
  • float to byte[]
  • Protobuf
  • C/C++
    • Containers
    • Basics
    • JNI
    • gcov
    • Castings
  • chess
    • Untitled
  • Compression
    • Untitled
  • Snippets
    • Untitled
  • Build Systems
    • Maven
    • Windows
  • Gradle
  • CMake
  • Java
    • Untitled
    • Certificates
  • Android
    • Mifare
  • Python
    • ctypes
  • WebSub
    • References
  • Spring Boot
    • Form-based Authentication
    • Basic Access Authentication
    • JWT Authentication
  • QR Code
    • Denso QR Code
  • Philosophical Inquiry
    • First
  • XML
    • xmlstarlet
Powered by GitBook
On this page

Was this helpful?

  1. C/C++

JNI

Pass 2d array from Java:

static void releaseMatrixArray(JNIEnv *env, jobjectArray matrix) 
{
	int size = env->GetArrayLength(matrix);
	
	for (int i = 0; i < size; i++) 
	{
		jfloatArray oneDim = (jfloatArray) env->GetObjectArrayElement(matrix, i);
		if (oneDim) {
		 jfloat *elements = env->GetFloatArrayElements(oneDim, 0);

		 env->ReleaseFloatArrayElements(oneDim, elements, 0);
		 env->DeleteLocalRef(oneDim);
		}
	}
}
PreviousBasicsNextgcov

Last updated 4 years ago

Was this helpful?