[DCM-1245] fix codes for mem leak
authorGwangbok Kim <gwangbok.kim@samsung.com>
Thu, 4 Apr 2013 08:58:25 +0000 (17:58 +0900)
committerGwangbok Kim <gwangbok.kim@samsung.com>
Fri, 5 Apr 2013 13:45:24 +0000 (22:45 +0900)
Change-Id: Ib70f5a11c661bd0caa8ab6423e0e4026819dc544
Signed-off-by: Gwangbok Kim <gwangbok.kim@samsung.com>
src/FScl_AddressbookManagerImpl.cpp
src/FScl_ContactImpl.cpp
src/FScl_UserProfileImpl.cpp

index 1d77e4b..d5512ea 100644 (file)
@@ -1751,18 +1751,28 @@ _AddressbookManagerImpl::ExportContactToVcardStreamN(const Contact& contact)
        ret = contacts_vcard_make_from_contact(recordHandle, &pVcardStream);
        SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
        SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
-
        SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       std::unique_ptr<char> pChar(pVcardStream);
-
        std::unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
-       SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       if (pByteBuffer == null)
+       {
+               free(pVcardStream);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       result r = pByteBuffer->Construct(strlen(pChar.get()));
-       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               return null;
+       }
+
+       result r = pByteBuffer->Construct(strlen(pVcardStream));
+       if (IsFailed(r))
+       {
+               free(pVcardStream);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pChar.get()), 0, strlen(pChar.get()));
+               return null;
+       }
+
+       r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+       free(pVcardStream);
        SysTryReturn(NID_SCL, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
        SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
 
@@ -1781,7 +1791,6 @@ _AddressbookManagerImpl::ExportContactsToVcardStreamN(const Tizen::Base::Collect
        int capacity = 0;
 
        contacts_record_h recordHandle = null;
-       std::unique_ptr<char> pChar(null);
 
        std::unique_ptr<IEnumerator> pEnum(contactList.GetEnumeratorN());
        SysTryReturn(NID_SCL, pEnum != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
@@ -1806,16 +1815,21 @@ _AddressbookManagerImpl::ExportContactsToVcardStreamN(const Tizen::Base::Collect
                ret = contacts_vcard_make_from_contact(recordHandle, &pVcardStream);
                SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
                SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
-
                SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-               pChar.reset(pVcardStream);
-
-               capacity += strlen(pChar.get());
+               capacity += strlen(pVcardStream);
                r = pByteBuffer->ExpandCapacity(capacity);
-               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               if (IsFailed(r))
+               {
+                       free(pVcardStream);
+                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       return null;
+               }
 
-               r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pChar.get()), 0, strlen(pChar.get()));
+               r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+               free(pVcardStream);
+               pVcardStream = null;
                SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.: capacity(%d), size(%d)", GetErrorMessage(E_SYSTEM));
        }
 
@@ -1845,15 +1859,26 @@ _AddressbookManagerImpl::ExportPersonToVcardStreamN(const Person& person)
        SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
        SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
 
-       std::unique_ptr<char> pChar(pVcardStream);
-
        std::unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
-       SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       if (pByteBuffer == null)
+       {
+               free(pVcardStream);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       result r = pByteBuffer->Construct(strlen(pChar.get()));
-       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               return null;
+       }
+
+       result r = pByteBuffer->Construct(strlen(pVcardStream));
+       if (IsFailed(r))
+       {
+               free(pVcardStream);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return null;
+       }
 
-       r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pChar.get()), 0, strlen(pChar.get()));
+       r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+       free(pVcardStream);
        SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
 
        return pByteBuffer.release();
@@ -1872,7 +1897,6 @@ _AddressbookManagerImpl::ExportPersonsToVcardStreamN(const Tizen::Base::Collecti
 
        contacts_record_h personRecordHandle = null;
        __ContactsRecordHandle recordHandle(null);
-       std::unique_ptr<char> pChar(null);
 
        std::unique_ptr<IEnumerator> pEnum(personList.GetEnumeratorN());
        SysTryReturn(NID_SCL, pEnum != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
@@ -1904,13 +1928,19 @@ _AddressbookManagerImpl::ExportPersonsToVcardStreamN(const Tizen::Base::Collecti
                SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
                SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
 
-               pChar.reset(pVcardStream);
-
-               capacity += strlen(pChar.get());
+               capacity += strlen(pVcardStream);
                r = pByteBuffer->ExpandCapacity(capacity);
-               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               if (IsFailed(r))
+               {
+                       free(pVcardStream);
+                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       return null;
+               }
 
-               r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pChar.get()), 0, strlen(pChar.get()));
+               r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+               free(pVcardStream);
+               pVcardStream = null;
                SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
        }
 
@@ -1934,31 +1964,60 @@ _AddressbookManagerImpl::ParseVcardStreamN(const Tizen::Base::ByteBuffer& vcardS
        contacts_list_get_count(listHandle, &count);
 
        std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
-       SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       if (pList == null)
+       {
+               contacts_list_destroy(listHandle, true);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return null;
+       }
 
        r = pList->Construct(count);
-       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       if (IsFailed(r))
+       {
+               contacts_list_destroy(listHandle, true);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return null;
+       }
 
        for (int i = 0; i < count; i++)
        {
                std::unique_ptr<Contact> pContact(new (std::nothrow) Contact());
-               SysTryReturn(NID_SCL, pContact != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               if (pContact == null)
+               {
+                       contacts_list_destroy(listHandle, true);
+                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-               contacts_list_get_current_record_p(listHandle, &recordHandle);
+                       return null;
+               }
 
-               _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(recordHandle);
                r = pList->Add(pContact.get());
-               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               if (IsFailed(r))
+               {
+                       contacts_list_destroy(listHandle, true);
+                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       return null;
+               }
 
                pContact.release();
+       }
+
+       std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               Contact* pContact = static_cast <Contact*> (pEnum->GetCurrent());
+
+               contacts_list_get_current_record_p(listHandle, &recordHandle);
+               _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(recordHandle);
 
                ret = contacts_list_next(listHandle);
-               if (ret != CONTACTS_ERROR_NONE)
-               {
-                       break;
-               }
        }
 
+       contacts_list_destroy(listHandle, false);
+
        return pList.release();
 }
 
@@ -1978,15 +2037,27 @@ _AddressbookManagerImpl::ExportUserProfileToVcardStreamN(const UserProfile& user
        SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
        SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       std::unique_ptr<char> pChar(pVcardStream);
-
        std::unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
+       if (pByteBuffer == null)
+       {
+               free(pVcardStream);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               return null;
+       }
        SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       result r = pByteBuffer->Construct(strlen(pChar.get()));
-       SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       result r = pByteBuffer->Construct(strlen(pVcardStream));
+       if (IsFailed(r))
+       {
+               free(pVcardStream);
+               SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pChar.get()), 0, strlen(pChar.get()));
+               return null;
+       }
+
+       r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+       free(pVcardStream);
        SysTryReturn(NID_SCL, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
        SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
 
@@ -2004,8 +2075,6 @@ _AddressbookManagerImpl::ExportUserProfilesToVcardStreamN(const Tizen::Base::Col
        result r = E_SUCCESS;
        int capacity = 0;
 
-       std::unique_ptr<char> pChar(null);
-
        std::unique_ptr<IEnumerator> pEnum(userProfileList.GetEnumeratorN());
        SysTryReturn(NID_SCL, pEnum != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -2033,13 +2102,18 @@ _AddressbookManagerImpl::ExportUserProfilesToVcardStreamN(const Tizen::Base::Col
                SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
                SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-               pChar.reset(pVcardStream);
-
-               capacity += strlen(pChar.get());
+               capacity += strlen(pVcardStream);
                r = pByteBuffer->ExpandCapacity(capacity);
-               SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               if (IsFailed(r))
+               {
+                       free(pVcardStream);
+                       SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       return null;
+               }
 
-               r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pChar.get()), 0, strlen(pChar.get()));
+               r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+               free(pVcardStream);
                SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.: capacity(%d), size(%d)", GetErrorMessage(E_SYSTEM));
        }
 
index 38f44f1..aa80582 100644 (file)
@@ -190,6 +190,7 @@ _ContactImpl::SetThumbnailPath(const Tizen::Base::String& filePath)
                else
                {
                        contacts_record_remove_child_record(__contactHandle, _contacts_contact.image, imageHandle);
+                       contacts_record_destroy(imageHandle, true);
                }
        }
        else
@@ -735,6 +736,7 @@ _ContactImpl::SetValue(ContactPropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(nameHandle))
                                {
                                        contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
                                }
                        }
                        else
@@ -767,6 +769,7 @@ _ContactImpl::SetValue(ContactPropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(nameHandle))
                                {
                                        contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
                                }
                        }
                        else
@@ -801,6 +804,7 @@ _ContactImpl::SetValue(ContactPropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(nameHandle))
                                {
                                        contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
                                }
                        }
                        else
@@ -834,6 +838,7 @@ _ContactImpl::SetValue(ContactPropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(nameHandle))
                                {
                                        contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
                                }
 
                        }
@@ -870,6 +875,7 @@ _ContactImpl::SetValue(ContactPropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(nameHandle))
                                {
                                        contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
                                }
                        }
                        else
@@ -913,6 +919,7 @@ _ContactImpl::SetValue(ContactPropertyId id, const String& value)
                                                }
 
                                                contacts_record_remove_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
+                                               contacts_record_destroy(nicknameHandle, true);
                                        }
                                }
                        }
@@ -956,6 +963,7 @@ _ContactImpl::SetValue(ContactPropertyId id, const String& value)
                                                }
 
                                                contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, companyHandle);
+                                               contacts_record_destroy(companyHandle, true);
                                        }
                                }
                        }
@@ -998,6 +1006,7 @@ _ContactImpl::SetValue(ContactPropertyId id, const String& value)
                                                }
 
                                                contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, companyHandle);
+                                               contacts_record_destroy(companyHandle, true);
                                        }
 
                                }
@@ -1043,6 +1052,7 @@ _ContactImpl::SetValue(ContactPropertyId id, const String& value)
                                                }
 
                                                contacts_record_remove_child_record(__contactHandle, _contacts_contact.note, noteHandle);
+                                               contacts_record_destroy(noteHandle, true);
                                        }
                                }
                        }
@@ -1090,6 +1100,7 @@ _ContactImpl::SetValue(ContactPropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
                                {
                                        contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
+                                       contacts_record_destroy(phoneticNameHandle, true);
                                }
                        }
                        else
@@ -1121,6 +1132,7 @@ _ContactImpl::SetValue(ContactPropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
                                {
                                        contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
+                                       contacts_record_destroy(phoneticNameHandle, true);
                                }
                        }
                        else
@@ -1152,6 +1164,7 @@ _ContactImpl::SetValue(ContactPropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
                                {
                                        contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
+                                       contacts_record_destroy(phoneticNameHandle, true);
                                }
                        }
                        else
@@ -2029,6 +2042,7 @@ _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, index, &recordHandle);
                contacts_record_remove_child_record(__contactHandle, _contacts_contact.number, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case CONTACT_MPROPERTY_ID_EMAILS:
@@ -2037,6 +2051,7 @@ _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, index, &recordHandle);
                contacts_record_remove_child_record(__contactHandle, _contacts_contact.email, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case CONTACT_MPROPERTY_ID_URLS:
@@ -2045,6 +2060,7 @@ _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, index, &recordHandle);
                contacts_record_remove_child_record(__contactHandle, _contacts_contact.url, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case CONTACT_MPROPERTY_ID_ADDRESSES:
@@ -2053,6 +2069,7 @@ _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, index, &recordHandle);
                contacts_record_remove_child_record(__contactHandle, _contacts_contact.address, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case CONTACT_MPROPERTY_ID_IMADDRESSES:
@@ -2061,6 +2078,7 @@ _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, index, &recordHandle);
                contacts_record_remove_child_record(__contactHandle, _contacts_contact.messenger, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case CONTACT_MPROPERTY_ID_ORGANIZATIONS:
@@ -2069,6 +2087,7 @@ _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, index, &recordHandle);
                contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case CONTACT_MPROPERTY_ID_EVENTS:
@@ -2077,6 +2096,7 @@ _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, index, &recordHandle);
                contacts_record_remove_child_record(__contactHandle, _contacts_contact.event, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case CONTACT_MPROPERTY_ID_RELATIONSHIPS:
@@ -2085,6 +2105,7 @@ _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, index, &recordHandle);
                contacts_record_remove_child_record(__contactHandle, _contacts_contact.relationship, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case CONTACT_MPROPERTY_ID_NOTES:
@@ -2093,6 +2114,7 @@ _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, index, &recordHandle);
                contacts_record_remove_child_record(__contactHandle, _contacts_contact.note, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case CONTACT_MPROPERTY_ID_NICKNAMES:
@@ -2101,6 +2123,7 @@ _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, index, &recordHandle);
                contacts_record_remove_child_record(__contactHandle, _contacts_contact.nickname, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        default:
index 608ac6a..596a0a5 100644 (file)
@@ -429,6 +429,7 @@ _UserProfileImpl::SetThumbnail(const String& filePath)
                else
                {
                        errCode = contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.image, imageHandle);
+                       contacts_record_destroy(imageHandle, true);
                        SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
                                                                "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
                }
@@ -489,6 +490,7 @@ _UserProfileImpl::SetValue(UserProfilePropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(nameHandle))
                                {
                                        contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
                                }
                        }
                        else
@@ -522,6 +524,7 @@ _UserProfileImpl::SetValue(UserProfilePropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(nameHandle))
                                {
                                        contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
                                }
                        }
                        else
@@ -557,6 +560,7 @@ _UserProfileImpl::SetValue(UserProfilePropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(nameHandle))
                                {
                                        contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
                                }
                        }
                        else
@@ -591,6 +595,7 @@ _UserProfileImpl::SetValue(UserProfilePropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(nameHandle))
                                {
                                        contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
                                }
 
                        }
@@ -627,6 +632,7 @@ _UserProfileImpl::SetValue(UserProfilePropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(nameHandle))
                                {
                                        contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
                                }
                        }
                        else
@@ -662,6 +668,7 @@ _UserProfileImpl::SetValue(UserProfilePropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(nameHandle))
                                {
                                        contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
                                }
                        }
                        else
@@ -697,6 +704,7 @@ _UserProfileImpl::SetValue(UserProfilePropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(nameHandle))
                                {
                                        contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
                                }
                        }
                        else
@@ -732,6 +740,7 @@ _UserProfileImpl::SetValue(UserProfilePropertyId id, const String& value)
                                if (value.IsEmpty() && IsEmptyName(nameHandle))
                                {
                                        contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
+                                       contacts_record_destroy(nameHandle, true);
                                }
                        }
                        else
@@ -2528,6 +2537,7 @@ _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &recordHandle);
                contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.number, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case USER_PROFILE_MPROPERTY_ID_EMAILS:
@@ -2536,6 +2546,7 @@ _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, &recordHandle);
                contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.email, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case USER_PROFILE_MPROPERTY_ID_URLS:
@@ -2544,6 +2555,7 @@ _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &recordHandle);
                contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.url, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case USER_PROFILE_MPROPERTY_ID_ADDRESSES:
@@ -2552,6 +2564,7 @@ _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &recordHandle);
                contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.address, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case USER_PROFILE_MPROPERTY_ID_IMADDRESSES:
@@ -2560,6 +2573,7 @@ _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &recordHandle);
                contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.messenger, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS:
@@ -2568,6 +2582,7 @@ _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &recordHandle);
                contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.company, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case USER_PROFILE_MPROPERTY_ID_EVENTS:
@@ -2576,6 +2591,7 @@ _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &recordHandle);
                contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.event, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS:
@@ -2584,6 +2600,7 @@ _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &recordHandle);
                contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.relationship, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case USER_PROFILE_MPROPERTY_ID_NOTES:
@@ -2592,6 +2609,7 @@ _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, &recordHandle);
                contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.note, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        case USER_PROFILE_MPROPERTY_ID_NICKNAMES:
@@ -2600,6 +2618,7 @@ _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
 
                contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &recordHandle);
                contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.nickname, recordHandle);
+               contacts_record_destroy(recordHandle, true);
 
                break;
        default:
@@ -2608,7 +2627,6 @@ _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
        }
 
        return E_SUCCESS;
-
 }
 
 IList*