Closed
Bug 972167
Opened 11 years ago
Closed 11 years ago
when copy constructing an nsAutoTArray it does not use its in-built buffer
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla30
People
(Reporter: heycam, Assigned: neil)
References
Details
Attachments
(1 file, 1 obsolete file)
769 bytes,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
(Found in bug 972078.) I find when I copy construct an nsAutoTArray from another nsAutoTArray that it does not end up invoking either of nsAutoBaseBase's two constructors, and thus doesn't call Init(). This means that mCapacity remains at 0 instead of the fixed internal buffer size, and will mean that the AppendElements call will always allocate memory even if there was enough space in the internal buffer.
Reporter | ||
Comment 1•11 years ago
|
||
Don't really know if this is the right thing, or why the existing explicit copy constructor on nsAutoTArray doesn't get called. But it does fix the problem I was having.
Assignee | ||
Comment 2•11 years ago
|
||
I don't think it's the right thing.
Comments in nsTArray.h correctly point out that nsTAutoArray's implicit copy constructor will use nsAutoArrayBase's copy constructor. Unfortunately the provided constructor is not a copy constructor because its argument is of the wrong type and so it doesn't get used.
How your patch worked was that it was an explicit constructor, so it can only use an explicit superclass constructor, in this case the default constructor, although you should have constructed Base explicitly using
explicit nsAutoTArray(const nsAutoTArray<E, N>& other) : Base(other) {}
Assignee: cam → neil
Attachment #8375295 -
Attachment is obsolete: true
Attachment #8375295 -
Flags: review?(benjamin)
Attachment #8375438 -
Flags: review?(benjamin)
Updated•11 years ago
|
Attachment #8375438 -
Flags: review?(benjamin) → review?(nfroyd)
Updated•11 years ago
|
Attachment #8375438 -
Flags: review?(nfroyd) → review+
Assignee | ||
Comment 3•11 years ago
|
||
Assignee | ||
Comment 4•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/c4393e9e9e21
Because the constructor was itself broken, although MSVC doesn't care.
Reporter | ||
Comment 5•11 years ago
|
||
Thanks for finding the correct fix Neil.
Comment 6•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/bba551f00ace
https://hg.mozilla.org/mozilla-central/rev/c4393e9e9e21
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
You need to log in
before you can comment on or make changes to this bug.
Description
•