Closed Bug 1233935 Opened 9 years ago Closed 8 years ago

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

Categories

(MailNews Core :: Backend, defect)

defect
Not set
normal

Tracking

(firefox46 affected)

RESOLVED FIXED
Thunderbird 47.0
Tracking Status
firefox46 --- affected

People

(Reporter: philip.chee, Assigned: jorgk-bmo)

References

Details

Attachments

(1 file, 1 obsolete file)

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.
Blocks: 1229985
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;
Fixed 3 of 5, patch coming ;-)
Assignee: nobody → mozilla
Status: NEW → ASSIGNED
Bug 1229985 (remove nsAutoArrayPtr) has landed on mozilla-inbound
I know, that's why I'm working on it. Now I've fixed 4 out of 5. Stand by for the patch ;-)
Attached patch 1233935.patch (v1) (obsolete) — Splinter Review
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+
Boy, that was quick, does that mean we can land it and won't actually have bustage ;-)
Attachment #8723737 - Attachment is obsolete: true
Attachment #8723781 - Flags: review+
Keywords: checkin-needed
https://hg.mozilla.org/comm-central/rev/d4f1823361ae
Status: ASSIGNED → RESOLVED
Closed: 8 years 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.

Attachment

General

Created:
Updated:
Size: