static const int _DATACONTROL_PACKET_INDEX_INSERTMAP = 6;
static const int _DATACONTROL_PACKET_INDEX_UPDATEMAP = 6;
+struct charDeleter
+{
+ void operator()(char* pValue)
+ {
+ if(pValue != null)
+ {
+ free(pValue);
+ pValue = null;
+ }
+ }
+};
+
_AppImpl::_AppImpl(App* pApp)
: __pCheckpointEventListener(null)
, __pSqlDataControlProviderEventListener(null)
// ptr to member function
(pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
- char* pOperation;
+ std::unique_ptr<char[], charDeleter> pOperation(null);
+ char* pBuf = null;
- int errVal = service_get_operation(service, &pOperation);
+ int errVal = service_get_operation(service, &pBuf);
+ pOperation.reset(pBuf);
- if((errVal == SERVICE_ERROR_NONE) && (!strcmp(pOperation, "osp.appsvc.operation.ALARM")))
+ if((errVal == SERVICE_ERROR_NONE) && (!strcmp((const char*)pOperation.get(), "osp.appsvc.operation.ALARM")))
{
- char* pAlarmId = null;
+ std::unique_ptr<char[], charDeleter> pAlarmId(null);
+ char* pBuf = null;
- errVal = service_get_extra_data(service, SERVICE_DATA_ALARM_ID, &pAlarmId);
+ errVal = service_get_extra_data(service, SERVICE_DATA_ALARM_ID, &pBuf);
+ pAlarmId.reset(pBuf);
SysTryReturnVoidResult(NID_SYS, errVal == SERVICE_ERROR_NONE, E_SYSTEM, "It is failed to get reserved alarm id.");
- int alarmId = atoi(pAlarmId);
+ int alarmId = atoi((const char*)pAlarmId.get());
_AlarmManager* pAlarmManager = _AlarmManager::GetInstance();
pAlarmManager->OnAlarmExpired(alarmId);
- if(pAlarmId != null)
- {
- free(pAlarmId);
- }
-
- free(pOperation);
-
return;
}
-
- if(pOperation)
- {
- free(pOperation);
- }
}
pAppImpl->__pIAppImpl->OnService(service, initialLaunch);