[android] fixed #488: fix memory leak

This commit is contained in:
minggo 2011-05-12 18:55:32 +08:00
parent 8e44d5bc40
commit 91bc9a3f7a
3 changed files with 10 additions and 4 deletions

View File

@ -109,7 +109,13 @@ string CCFileUtils::getWriteablePath()
{
// the path is: /data/data/ + package name
string dir("/data/data/");
return dir + getPackageNameJNI() + "/" ;
char* tmp = getPackageNameJNI();
dir += tmp + "/" ;
// release memory
delete tmp;
return dir;
}
NS_CC_END;

View File

@ -404,10 +404,10 @@ extern "C"
return rtn;
}
const char* getPackageNameJNI()
char* getPackageNameJNI()
{
TMethodJNI t;
const char* ret = NULL;
char* ret = NULL;
if (getMethodID(t
, "org/cocos2dx/lib/Cocos2dxActivity"

View File

@ -34,7 +34,7 @@ extern "C"
void disableAccelerometerJNI();
void showMessageBoxJNI(const char * pszMsg, const char * pszTitle);
void setKeyboardStateJNI(int bOpen);
const char* getPackageNameJNI();
char* getPackageNameJNI();
}
#endif // __ANDROID_COCOS2D_JNI_H__