ndk的内存释放:
//回收 (*env)->ReleaseIntArrayElements(env,value, codeLineArray,0); (*env)->ReleaseIntArrayElements(env,(jintArray)codeLineArray, codeLineData,0); (*env)->DeleteLocalRef(env, value); (*env)->DeleteLocalRef(env, codeLineArray); (*env)->DeleteLocalRef(env, codeLineData); value=NULL; codeLineArray = NULL; codeLineData=NULL;
//init char *ret = malloc(1); strcpy(ret, ""); //add char char addchar[]={'\n'}; strcat(ret, addchar);
读取
jintArray textBinArr = (jintArray)(*env)->CallObjectMethod(env,code,valueGetMethod,firstKey); int codeHeight = (*env)->GetArrayLength(env, textBinArr); LOGI("codeHeight:%d",codeHeight); int picHeight = (*env)->GetArrayLength(env, pic); LOGI("picHeight==%d",picHeight); for (i = 0; i < picHeight; i+=picHeight) { jarray lineArray = ((*env)->GetObjectArrayElement(env, pic, i)); int picWidth = (*env)->GetArrayLength(env, lineArray); jboolean *lineData = (*env)->GetBooleanArrayElements(env, (jbooleanArray)lineArray, 0 ); for (j=0;j<picWidth;) { //[i][j]=lineData[j] } }生成:
//new boolean[][] jobjectArray ret; jclass boolArrCls = (*env)->FindClass(env, "[Z"); if ( NULL== boolArrCls) { return NULL; } ret = (*env)->NewObjectArray(env, info.height , boolArrCls, NULL); jboolean tmp[info.width];//固定数组,测试用,注意别溢出 for (int i=0 to 100) { jbooleanArray boolArr = (*env)->NewBooleanArray(env,width); for (j 0 to 1000) { tem[j]=randonInt(); } (*env)->SetBooleanArrayRegion(env,boolArr, 0, width, tmp); (*env)->SetObjectArrayElement(env,ret, y, boolArr); (*env)->DeleteLocalRef(env,boolArr); }
吐槽一下今天:
几个20多岁的朋友都想过6.1,是不是脑子都抽水了?
NDK代码量比java多了好多;
打算去北京,好多人反对;
还没女朋友~