Commit bd0ca7a6 by app_dev@sobot.com

内存泄漏优化

parent 5adb637c
No preview for this file type
......@@ -52,14 +52,15 @@ JNIEXPORT jstring JNICALL Java_com_sobot_chat_core_SobotUtil_getKey
char *aa =jstringToChar(env,a);
char *cc =jstringToChar(env,c);
char *dd =jstringToChar(env,d);
char *result = (char *) malloc(strlen(aa) + strlen(dd)+ strlen(cc)+ strlen(getKey()));
int len = strlen(aa) + strlen(dd)+ strlen(cc)+ strlen(getKey())+1;
char *result = (char *) malloc(len);
memset(result,0,len);
sprintf(result, "%s%s%s%s", aa,dd,cc,getKey());
MD5_CTX context = { 0 };
MD5Init(&context);
MD5Update(&context, result, strlen(result));
unsigned char dest[16] = { 0 };
MD5Final(dest, &context);
(*env)->ReleaseStringUTFChars(env, c, result);
int i = 0;
char szMd5[33] = { 0 };
......@@ -67,6 +68,9 @@ JNIEXPORT jstring JNICALL Java_com_sobot_chat_core_SobotUtil_getKey
{
sprintf(szMd5, "%s%02x", szMd5, dest[i]);
}
free((void*)aa);
free((void*)cc);
free((void*)dd);
free((void*)result);
return (*env)->NewStringUTF(env, szMd5);
}
}
\ No newline at end of file
**android Studio 基于NDK加密,防止反编译获取加密key**
**android Studio 基于NDK加密,防止反编译获取加密key**
......@@ -95,6 +95,8 @@ sobot.c
6. 打开命令窗口,进入jni文件夹,执行命令 **ndk-build** ,会自动生成一个libs文件夹。里边的 .so 文件供调用
注意:有时候出现找不到ndk-build,1、看下环境变量里有没ndk路径, 2、执行source .bash_profile,然后在进入jni文件夹下,执行ndk-build
三、调用生成的 .so文件
1. 把so文件复制到module下的libs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment