fix memory leak
authorYoung Ik Cho <youngik.cho@samsung.com>
Tue, 30 Apr 2013 11:51:06 +0000 (20:51 +0900)
committerYoung Ik Cho <youngik.cho@samsung.com>
Tue, 30 Apr 2013 11:51:06 +0000 (20:51 +0900)
Change-Id: I28f11174ec7931566e25b96b97553172a75e9579
Signed-off-by: Young Ik Cho <youngik.cho@samsung.com>
plugins/accessory-condition-handler/AccessoryMonitor.cpp
plugins/alarm-condition-handler/AlarmConditionHandler.cpp
src/AppService.cpp
src/FApp_ConditionManagerService.cpp
src/FSys_AccessoryManagerService.cpp

index ade6116..c48172a 100644 (file)
@@ -109,7 +109,7 @@ AccessoryMonitor::ReleaseInstance(void)
 void
 AccessoryMonitor::OnDataRouterDataReceivedN(const char* buffer, int length)
 {
-       result r = E_SUCCESS;
+       //result r = E_SUCCESS;
        SysLog(NID_SYS, "serial data is forwarded to AccessoryMonitor class");
        SysTryReturnVoidResult(NID_SYS, buffer != null, E_INVALID_ARG, "[E_INVALID_ARG] buffer should not be null.");
 
index 7c9f6fd..5e6287f 100644 (file)
@@ -108,13 +108,13 @@ _AlarmConditionHandler::Convert(_AppLaunchCondition& appLaunchCondition, struct
        if(buf.StartsWith(L"DueTime", 0) == true)
        {
 
-               ret = sscanf(convertedString.get(), "DueTime='%d/%d/%d %d:%d:%d' LaunchPeriod='%d'%s", &(pConvertedTime->tm_mon), &(pConvertedTime->tm_mday), &(pConvertedTime->tm_year), &(pConvertedTime->tm_hour), &(pConvertedTime->tm_min), &(pConvertedTime->tm_sec), &period, &garbage);
+               ret = sscanf(convertedString.get(), "DueTime='%d/%d/%d %d:%d:%d' LaunchPeriod='%d'%s", &(pConvertedTime->tm_mon), &(pConvertedTime->tm_mday), &(pConvertedTime->tm_year), &(pConvertedTime->tm_hour), &(pConvertedTime->tm_min), &(pConvertedTime->tm_sec), &period, garbage);
 
                SysTryReturnResult(NID_SYS, ret == 7, E_INVALID_FORMAT, "The specified condition format is not compatible.");
        }
        else if(buf.StartsWith(L"DateTime", 0) == true)
        {
-               ret = sscanf(convertedString.get(), "DateTime='%d/%d/%d %d:%d:%d'%s", &(pConvertedTime->tm_mon), &(pConvertedTime->tm_mday), &(pConvertedTime->tm_year), &(pConvertedTime->tm_hour), &(pConvertedTime->tm_min), &(pConvertedTime->tm_sec), &garbage);
+               ret = sscanf(convertedString.get(), "DateTime='%d/%d/%d %d:%d:%d'%s", &(pConvertedTime->tm_mon), &(pConvertedTime->tm_mday), &(pConvertedTime->tm_year), &(pConvertedTime->tm_hour), &(pConvertedTime->tm_min), &(pConvertedTime->tm_sec), garbage);
                SysTryReturnResult(NID_SYS, ret == 6, E_INVALID_FORMAT, "The specified condition format is not compatible.");   
        }
        else
@@ -149,7 +149,7 @@ _AlarmConditionHandler::Convert(Tizen::Base::String& appLaunchCondition, struct
        unique_ptr<char[]> convertedString(_StringConverter::CopyToCharArrayN(buf));
        SysTryReturnResult(NID_SYS, convertedString.get() != null, E_OUT_OF_MEMORY, "Memory allocation failure.");
 
-       ret = sscanf(convertedString.get(), "'%*s %d:%d:%d'%s", &(pConvertedTime->tm_hour), &(pConvertedTime->tm_min), &(pConvertedTime->tm_sec), &garbage);
+       ret = sscanf(convertedString.get(), "'%*s %d:%d:%d'%s", &(pConvertedTime->tm_hour), &(pConvertedTime->tm_min), &(pConvertedTime->tm_sec), garbage);
        SysTryReturnResult(NID_SYS, ret == 3, E_INVALID_FORMAT, "The specified condition format is not compatible.");
 
        DateTime currentTime;
@@ -202,7 +202,7 @@ _AlarmConditionHandler::Register( _AppLaunchCondition& appLaunchCondition)
        char* packageName = null;
        service_h service = null;
        DateTime validateCheck;
-       _AppLaunchCondition* pReservedCondition = null;
+       //_AppLaunchCondition* pReservedCondition = null;
 
        if(appLaunchCondition.GetConditionString().StartsWith(L"WeeklyTime", 0) == true)
        {
index b36557e..aa2d194 100644 (file)
@@ -481,24 +481,18 @@ AppService::RegisterPreloadedAppCondition(void)
 {
        SysLog(NID_APP, "Enter.");
 
-       HashMap packageFilterMap(SingleObjectDeleter);
+       HashMap packageFilterMap;
        packageFilterMap.Construct();
 
-       String* pDownloadKey = new String("http://tizen.org/package/downloaded");
-        SysTryReturnVoidResult(NID_APP, pDownloadKey != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Creating a key gets failed.");
+       String downloadKey = "http://tizen.org/package/downloaded";
+       Boolean downloadValue = false;
 
-        Boolean* pDownloadValue = new Boolean(false);
-        SysTryReturnVoidResult(NID_APP, pDownloadValue != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Creating a value gets failed.");
+       result r = packageFilterMap.Add(&downloadKey, &downloadValue);
 
-        result r = packageFilterMap.Add(pDownloadKey, pDownloadValue);
+       String extKey = "http://tizen.org/package/tpk";
+       Boolean extValue = true;
 
-        String* pExtKey = new String("http://tizen.org/package/tpk");
-        SysTryReturnVoidResult(NID_APP, pExtKey != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Creating a key gets failed.");
-
-        Boolean* pExtValue = new Boolean(true);
-        SysTryReturnVoidResult(NID_APP, pExtValue != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Creating a value gets failed.");
-
-        r = packageFilterMap.Add(pExtKey, pExtValue);
+       r = packageFilterMap.Add(&extKey, &extValue);
 
        IList* pList = _PackageManagerImpl::GetInstance()->GetPackageInfoListN(packageFilterMap);
        if (pList)
@@ -721,7 +715,7 @@ AppService::_TaskHandlerThread::OnUserEventReceivedN(RequestId reqId, IList* pAr
        {
        case HANDLER_REQUEST_INSTALL_COMPLETE:
        {
-               String isLaunchOnBoot = _ContextManager::_Util::QueryFeatureFromPackageManager(*pPackageName, *pExecName, L"LaunchOnBoot" );
+               const String& isLaunchOnBoot = _ContextManager::_Util::QueryFeatureFromPackageManager(*pPackageName, *pExecName, L"LaunchOnBoot" );
                if ( isLaunchOnBoot == L"True")
                {
 //                     String realId = *pAppId + '.' + *pExecName;
index edd47b5..1ddbf3e 100644 (file)
@@ -73,7 +73,7 @@ _ConditionManagerService::~_ConditionManagerService()
        _ConditionHandler* pHandler = null;
        for (int i =0; i < __handlers.GetCount(); i ++)
        {
-               pHandler = null;
+               _ConditionHandler* pHandler = null;
                r = __handlers.GetAt(i, pHandler);
                delete pHandler;
        }
@@ -151,6 +151,7 @@ _ConditionManagerService::InitializePlugins(void)
        }
 
        pSections->RemoveAll(true);
+       delete pSections;
 
        SysLog(NID_APP,"Exit.");
        return E_SUCCESS;
@@ -158,6 +159,7 @@ _ConditionManagerService::InitializePlugins(void)
 CATCH:
        SysLog(NID_APP,"Catch.");
        pSections->RemoveAll(true);
+       delete pSections;
 
        return r;
 }
index d426524..191956b 100644 (file)
@@ -100,6 +100,8 @@ _AccessoryManagerService::~_AccessoryManagerService()
 {
        result r = E_SUCCESS;
 
+       delete __pLib;
+
        SysTryCatch(NID_SYS, __pCommunicationDispatcher != null, r = E_SYSTEM, E_SYSTEM, "_CommunicationDispatcher is not initiated.");
 
        r = __pCommunicationDispatcher->RemoveCommunicationEventListener(*this);