fix memory leak
authorGwangbok Kim <gwangbok.kim@samsung.com>
Wed, 23 Oct 2013 11:10:59 +0000 (20:10 +0900)
committerGwangbok Kim <gwangbok.kim@samsung.com>
Fri, 25 Oct 2013 02:02:16 +0000 (11:02 +0900)
Change-Id: Icb32e90ddfe99bceeb7e7dfd11afd617344564b8
Signed-off-by: Gwangbok Kim <gwangbok.kim@samsung.com>
src/FScl_AddressbookImpl.cpp
src/FScl_AddressbookUtil.h
src/inc/FScl_AddressbookImpl.h

index 2717ccf..e82917b 100644 (file)
@@ -429,7 +429,7 @@ _AddressbookImpl::UpdateContact(const Contact& contact)
        SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
        unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_simple_contact._uri, contactId));
-        SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
        int intValue = 0;
        contacts_record_get_int(pContactRecord.get(), _contacts_simple_contact.id, &intValue);
@@ -540,7 +540,7 @@ _AddressbookImpl::UpdateContact(const Contact& contact)
                SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
        }
        pContactRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, contact.GetRecordId()));
-        SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
        _ContactImpl::GetInstance(*const_cast<Contact*>(&contact))->SetContactRecordHandle(pContactRecord.release());
 
@@ -1276,8 +1276,8 @@ _AddressbookImpl::UpdateContacts(const Tizen::Base::Collection::IList& contactLi
        }
 
        result r = _AddressbookUtil::UpdateContactRecords(listHandle);
-       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
        contacts_list_destroy(listHandle, false);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        return E_SUCCESS;
 }
@@ -1352,16 +1352,14 @@ _AddressbookImpl::SetUserProfile(const UserProfile* pUserProfile)
                        ret = contacts_record_clone(recordHandle, &newRecordHandle);
                        SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-                       ret = contacts_record_set_int(newRecordHandle, _contacts_my_profile.address_book_id, __addressbookId);
-                       if (ret != CONTACTS_ERROR_NONE)
-                       {
-                               contacts_record_destroy(newRecordHandle, true);
-                               SysLogException(NID_SCL, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
-                               return E_SYSTEM;
-                       }
+                       unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(newRecordHandle);
+                       SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       ret = contacts_record_set_int(pContactRecord.get(), _contacts_my_profile.address_book_id, __addressbookId);
+                       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
 
                        int recordId = 0;
-                       result r = _AddressbookUtil::InsertContactRecordN(newRecordHandle, recordId);
+                       result r = _AddressbookUtil::InsertContactRecordN(pContactRecord.get(), recordId);
                        SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
                }
                else if (recordId > 0)
@@ -1373,8 +1371,8 @@ _AddressbookImpl::SetUserProfile(const UserProfile* pUserProfile)
                                SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                                result r = _AddressbookUtil::UpdateContactRecord(newRecordHandle);
-                               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
                                contacts_record_destroy(newRecordHandle, true);
+                               SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
                        }
                        else
                        {
@@ -1384,29 +1382,15 @@ _AddressbookImpl::SetUserProfile(const UserProfile* pUserProfile)
                                        SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
                                }
 
-                               contacts_record_h newRecordHandle = null;
-                               ret = contacts_record_create(_contacts_my_profile._uri, &newRecordHandle);
-                               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
-                               r = CopyMyProfileContents(recordHandle, newRecordHandle);
-                               if (r != E_SUCCESS)
-                               {
-                                       contacts_record_destroy(newRecordHandle, true);
-                                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-                                       return E_OUT_OF_MEMORY;
-
-                               }
+                               unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(CopyMyProfileRecordHandle(recordHandle));
+                               SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
-                               ret = contacts_record_set_int(newRecordHandle, _contacts_my_profile.address_book_id, __addressbookId);
-                               if (ret != CONTACTS_ERROR_NONE)
-                               {
-                                       contacts_record_destroy(newRecordHandle, true);
-                                       SysLogException(NID_SCL, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
-                                       return E_SYSTEM;
-                               }
+                               ret = contacts_record_set_int(pContactRecord.get(), _contacts_my_profile.address_book_id, __addressbookId);
+                               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
 
                                int recordId = 0;
-                               result r = _AddressbookUtil::InsertContactRecordN(newRecordHandle, recordId);
+
+                               r = _AddressbookUtil::InsertContactRecordN(pContactRecord.get(), recordId);
                                SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
                        }
                }
@@ -1477,18 +1461,24 @@ _AddressbookImpl::IsUserProfileChangedAfter(int version) const
        return false;
 }
 
-result
-_AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_record_h dstHandle)
+contacts_record_h
+_AddressbookImpl::CopyMyProfileRecordHandle(contacts_record_h srcHandle)
 {
+       ClearLastResult();
+
        int ret = CONTACTS_ERROR_NONE;
        int intValue = 0;
        unsigned int count = 0;
        unsigned int i = 0;
        char* pCharValue = null;
 
+       contacts_record_h contactHandle = null;
        contacts_record_h srcRecordHandle = null;
        contacts_record_h dstRecordHandle = null;
 
+       ret = contacts_record_create(_contacts_my_profile._uri, &contactHandle);
+       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
        // name
        contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.name, &count);
        if (count > 0)
@@ -1496,35 +1486,35 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.name, 0, &srcRecordHandle);
 
                ret = contacts_record_create(_contacts_name._uri, &dstRecordHandle);
-               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                __ContactsRecordHandle nameHandle(dstRecordHandle);
 
-               contacts_record_get_str(srcRecordHandle, _contacts_name.first, &pCharValue);
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.first, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_name.first, pCharValue);
 
-               contacts_record_get_str(srcRecordHandle, _contacts_name.last, &pCharValue);
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.last, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_name.last, pCharValue);
 
-               contacts_record_get_str(srcRecordHandle, _contacts_name.addition, &pCharValue);
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.addition, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_name.addition, pCharValue);
 
-               contacts_record_get_str(srcRecordHandle, _contacts_name.suffix, &pCharValue);
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.suffix, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_name.suffix, pCharValue);
 
-               contacts_record_get_str(srcRecordHandle, _contacts_name.prefix, &pCharValue);
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.prefix, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_name.prefix, pCharValue);
 
-               contacts_record_get_str(srcRecordHandle, _contacts_name.phonetic_first, &pCharValue);
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.phonetic_first, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_name.phonetic_first, pCharValue);
 
-               contacts_record_get_str(srcRecordHandle, _contacts_name.phonetic_middle, &pCharValue);
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.phonetic_middle, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_name.phonetic_middle, pCharValue);
 
-               contacts_record_get_str(srcRecordHandle, _contacts_name.phonetic_last, &pCharValue);
+               contacts_record_get_str_p(srcRecordHandle, _contacts_name.phonetic_last, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_name.phonetic_last, pCharValue);
 
-               contacts_record_add_child_record(dstHandle, _contacts_my_profile.name, dstRecordHandle);
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.name, dstRecordHandle);
 
                nameHandle.Release();
        }
@@ -1536,7 +1526,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.company, i, &srcRecordHandle);
 
                ret = contacts_record_create(_contacts_company._uri, &dstRecordHandle);
-               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                __ContactsRecordHandle companyHandle(dstRecordHandle);
 
@@ -1570,7 +1560,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_str_p(srcRecordHandle, _contacts_company.phonetic_name, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_company.phonetic_name, pCharValue);
 
-               contacts_record_add_child_record(dstHandle, _contacts_my_profile.company, dstRecordHandle);
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.company, dstRecordHandle);
 
                companyHandle.Release();
        }
@@ -1582,14 +1572,14 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.note, i, &srcRecordHandle);
 
                ret = contacts_record_create(_contacts_note._uri, &dstRecordHandle);
-               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                __ContactsRecordHandle noteHandle(dstRecordHandle);
 
                contacts_record_get_str_p(srcRecordHandle, _contacts_note.note, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_note.note, pCharValue);
 
-               contacts_record_add_child_record(dstHandle, _contacts_my_profile.note, dstRecordHandle);
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.note, dstRecordHandle);
 
                noteHandle.Release();
        }
@@ -1601,7 +1591,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.number, i, &srcRecordHandle);
 
                ret = contacts_record_create(_contacts_number._uri, &dstRecordHandle);
-               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                __ContactsRecordHandle numberHandle(dstRecordHandle);
 
@@ -1614,7 +1604,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_str_p(srcRecordHandle, _contacts_number.number, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_number.number, pCharValue);
 
-               contacts_record_add_child_record(dstHandle, _contacts_my_profile.number, dstRecordHandle);
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.number, dstRecordHandle);
 
                numberHandle.Release();
        }
@@ -1626,7 +1616,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.email, i, &srcRecordHandle);
 
                ret = contacts_record_create(_contacts_email._uri, &dstRecordHandle);
-               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                __ContactsRecordHandle emailHandle(dstRecordHandle);
 
@@ -1639,7 +1629,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_str_p(srcRecordHandle, _contacts_email.email, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_email.email, pCharValue);
 
-               contacts_record_add_child_record(dstHandle, _contacts_my_profile.email, dstRecordHandle);
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.email, dstRecordHandle);
 
                emailHandle.Release();
 
@@ -1652,7 +1642,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.event, i, &srcRecordHandle);
 
                ret = contacts_record_create(_contacts_event._uri, &dstRecordHandle);
-               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                __ContactsRecordHandle eventHandle(dstRecordHandle);
 
@@ -1665,7 +1655,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_int(srcRecordHandle, _contacts_event.date, &intValue);
                contacts_record_set_int(dstRecordHandle, _contacts_event.date, intValue);
 
-               contacts_record_add_child_record(dstHandle, _contacts_my_profile.event, dstRecordHandle);
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.event, dstRecordHandle);
 
                eventHandle.Release();
        }
@@ -1677,7 +1667,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.messenger, i, &srcRecordHandle);
 
                ret = contacts_record_create(_contacts_messenger._uri, &dstRecordHandle);
-               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                __ContactsRecordHandle imAddressHandle(dstRecordHandle);
 
@@ -1690,7 +1680,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_str_p(srcRecordHandle, _contacts_messenger.im_id, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_messenger.im_id, pCharValue);
 
-               contacts_record_add_child_record(dstHandle, _contacts_my_profile.messenger, dstRecordHandle);
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.messenger, dstRecordHandle);
 
                imAddressHandle.Release();
        }
@@ -1702,7 +1692,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.address, i, &srcRecordHandle);
 
                ret = contacts_record_create(_contacts_address._uri, &dstRecordHandle);
-               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                __ContactsRecordHandle addressHandle(dstRecordHandle);
 
@@ -1733,7 +1723,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_str_p(srcRecordHandle, _contacts_address.country, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_address.country, pCharValue);
 
-               contacts_record_add_child_record(dstHandle, _contacts_my_profile.address, dstRecordHandle);
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.address, dstRecordHandle);
 
                addressHandle.Release();
        }
@@ -1745,7 +1735,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.url, i, &srcRecordHandle);
 
                ret = contacts_record_create(_contacts_url._uri, &dstRecordHandle);
-               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                __ContactsRecordHandle urlHandle(dstRecordHandle);
 
@@ -1758,7 +1748,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_str_p(srcRecordHandle, _contacts_url.url, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_url.url, pCharValue);
 
-               contacts_record_add_child_record(dstHandle, _contacts_my_profile.url, dstRecordHandle);
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.url, dstRecordHandle);
 
                urlHandle.Release();
        }
@@ -1770,14 +1760,14 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.nickname, i, &srcRecordHandle);
 
                ret = contacts_record_create(_contacts_nickname._uri, &dstRecordHandle);
-               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                __ContactsRecordHandle nicknameHandle(dstRecordHandle);
 
                contacts_record_get_str_p(srcRecordHandle, _contacts_nickname.name, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_nickname.name, pCharValue);
 
-               contacts_record_add_child_record(dstHandle, _contacts_my_profile.nickname, dstRecordHandle);
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.nickname, dstRecordHandle);
 
                nicknameHandle.Release();
        }
@@ -1789,14 +1779,14 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.relationship, i, &srcRecordHandle);
 
                ret = contacts_record_create(_contacts_relationship._uri, &dstRecordHandle);
-               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                __ContactsRecordHandle relationshipHandle(dstRecordHandle);
 
                contacts_record_get_str_p(srcRecordHandle, _contacts_relationship.name, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_relationship.name, pCharValue);
 
-               contacts_record_add_child_record(dstHandle, _contacts_my_profile.relationship, dstRecordHandle);
+               contacts_record_add_child_record(contactHandle, _contacts_my_profile.relationship, dstRecordHandle);
 
                relationshipHandle.Release();
        }
@@ -1812,7 +1802,7 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.image, 0, &srcRecordHandle);
 
                ret = contacts_record_create(_contacts_image._uri, &dstRecordHandle);
-               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
                __ContactsRecordHandle imageHandle(dstRecordHandle);
 
@@ -1825,12 +1815,12 @@ _AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_re
                contacts_record_get_str_p(srcRecordHandle, _contacts_image.path, &pCharValue);
                contacts_record_set_str(dstRecordHandle, _contacts_image.path, pCharValue);
 
-               contacts_record_add_child_record(dstHandle, _contacts_contact.image, dstRecordHandle);
+               contacts_record_add_child_record(contactHandle, _contacts_contact.image, dstRecordHandle);
 
                imageHandle.Release();
        }
 
-       return E_SUCCESS;
+       return contactHandle;
 }
 
 contacts_record_h
index 31308fd..a1e04e0 100644 (file)
@@ -45,7 +45,6 @@ struct ContactRecordDeleter
        }
 };
 
-
 class __ContactsRecordHandle
 {
 public:
index 4cdb5ed..85be77e 100644 (file)
@@ -161,7 +161,7 @@ public:
 
        bool IsUserProfileChangedAfter(int version) const;
 
-       result CopyMyProfileContents(contacts_record_h srcHandle, contacts_record_h dstHandle);
+       contacts_record_h CopyMyProfileRecordHandle(contacts_record_h srcHandle);
 
        virtual void OnContactChanged(void);