The default bug view has changed. See this FAQ.

use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in mailnews/

RESOLVED FIXED in Thunderbird 47.0

Status

MailNews Core
Backend
RESOLVED FIXED
a year ago
a year ago

People

(Reporter: Philip Chee, Assigned: Jorg K (GMT+1))

Tracking

Trunk
Thunderbird 47.0

Firefox Tracking Flags

(firefox46 affected)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

a year ago
UniquePtr<T[]> is better and encourages people to write clearer code.

nsAutoArrayPtr should be converted to use UniquePtr<T[]> instead; the idiomatic way of declaring and defining a UniquePtr is:

auto var = MakeUnique<T[]>(length);

Since nsAutoArrayPtr implicitly converts to T* and UniquePtr does not, you'll have to add |.get()| calls for all uses of the raw pointer.  Accesses such as |var[i]| do not need any special treatment.
(Reporter)

Updated

a year ago
Blocks: 1229985
(Assignee)

Comment 1

a year ago
This is a small problem, 5 occurrences:

https://dxr.mozilla.org/comm-central/search?q=nsAutoArrayPtr&redirect=false&case=false
mailnews/base/search/src/nsMsgSearchAdapter.cpp
555 	nsAutoArrayPtr<char> newValue(new char[2*strlen(vptr) + 1]);
mailnews/base/src/nsMsgSearchDBView.cpp
782 	nsAutoArrayPtr<nsTArray<uint32_t> > indexArrays;
mailnews/base/util/nsMsgCompressIStream.h
28 	nsAutoArrayPtr<char> m_zbuf;
29 	nsAutoArrayPtr<char> m_databuf;
mailnews/base/util/nsMsgCompressOStream.h
25 	nsAutoArrayPtr<char> m_zbuf;
(Assignee)

Comment 2

a year ago
Fixed 3 of 5, patch coming ;-)
Assignee: nobody → mozilla
Status: NEW → ASSIGNED
(Reporter)

Comment 3

a year ago
Bug 1229985 (remove nsAutoArrayPtr) has landed on mozilla-inbound
(Assignee)

Comment 4

a year ago
I know, that's why I'm working on it. Now I've fixed 4 out of 5. Stand by for the patch ;-)
(Assignee)

Comment 5

a year ago
Created attachment 8723737 [details] [diff] [review]
1233935.patch (v1)

Sorry about the r?-SPAM. This is a pre-active bustage fix, please review asap. One review only ;-)
Attachment #8723737 - Flags: review?(rkent)
Attachment #8723737 - Flags: review?(mkmelin+mozilla)
Attachment #8723737 - Flags: review?(Pidgeot18)
Comment on attachment 8723737 [details] [diff] [review]
1233935.patch (v1)

Review of attachment 8723737 [details] [diff] [review]:
-----------------------------------------------------------------

rs=me

::: mailnews/base/src/nsMsgSearchDBView.cpp
@@ +882,5 @@
>  
>  nsresult
> +nsMsgSearchDBView::PartitionSelectionByFolder(nsMsgViewIndex *indices,
> +                                              int32_t numIndices,
> +                                              mozilla::UniquePtr<nsTArray<uint32_t>[]>& indexArrays,

Nit: &indexArrays, not & indexArrays. Although this is a nasty typename in general, not that I see a way around it.
Attachment #8723737 - Flags: review?(rkent)
Attachment #8723737 - Flags: review?(mkmelin+mozilla)
Attachment #8723737 - Flags: review?(Pidgeot18)
Attachment #8723737 - Flags: review+
(Assignee)

Comment 7

a year ago
Created attachment 8723781 [details] [diff] [review]
1233935.patch (v2) - nit fixed

Boy, that was quick, does that mean we can land it and won't actually have bustage ;-)
Attachment #8723737 - Attachment is obsolete: true
(Assignee)

Updated

a year ago
Attachment #8723781 - Flags: review+
(Assignee)

Updated

a year ago
Keywords: checkin-needed
(Assignee)

Comment 8

a year ago
https://hg.mozilla.org/comm-central/rev/d4f1823361ae
Status: ASSIGNED → RESOLVED
Last Resolved: a year ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 47.0
You need to log in before you can comment on or make changes to this bug.