[vlmc-devel] [PATCH 2/2] Use delete[]
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Mon Apr 4 10:18:15 CEST 2016
On 04/02/2016 11:40 AM, yikei lu wrote:
> QSharedPointer or std::shared_ptr ?
>
> 2016-04-02 18:39 GMT+09:00 Hugo Beauzée-Luyssen <hugo at beauzee.fr>:
>> On 04/02/2016 07:45 AM, Yikai Lu wrote:
>>>
>>> Since buff is created by new uchar[], delete[] should be used to delete it
>>> completely.
>>> ---
>>> src/Workflow/AudioClipWorkflow.cpp | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/src/Workflow/AudioClipWorkflow.cpp
>>> b/src/Workflow/AudioClipWorkflow.cpp
>>> index 3b08877..c119c29 100644
>>> --- a/src/Workflow/AudioClipWorkflow.cpp
>>> +++ b/src/Workflow/AudioClipWorkflow.cpp
>>> @@ -52,13 +52,13 @@ AudioClipWorkflow::releasePrealocated()
>>> while ( m_availableBuffers.isEmpty() == false )
>>> {
>>> Workflow::AudioSample *as = m_availableBuffers.takeFirst();
>>> - delete as->buff;
>>> + delete[] as->buff;
>>> delete as;
>>> }
>>> while ( m_computedBuffers.isEmpty() == false )
>>> {
>>> Workflow::AudioSample *as = m_computedBuffers.takeFirst();
>>> - delete as->buff;
>>> + delete[] as->buff;
>>> delete as;
>>> }
>>> }
>>>
>> It might be time we start using some smart pointers for the buffers as well,
>> we shouldn't have to deal with this manually IMHO
>>
>> _______________________________________________
>> Vlmc-devel mailing list
>> Vlmc-devel at videolan.org
>> https://mailman.videolan.org/listinfo/vlmc-devel
> _______________________________________________
> Vlmc-devel mailing list
> Vlmc-devel at videolan.org
> https://mailman.videolan.org/listinfo/vlmc-devel
>
I'd be more inclined to use shared_ptr. Mostly because Qt doesn't seem
to provide an equivalent to unique_ptr, and I'd like to avoid having
both QSharedPointer & std::unique_ptr
Regards,
More information about the Vlmc-devel
mailing list