Bug 113277

Summary: RefCountedArray needs a size based constructor
Product: WebKit Reporter: Oliver Hunt <oliver>
Component: New BugsAssignee: Oliver Hunt <oliver>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cmarcelo, ojan.autocc, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch benjamin: review+

Oliver Hunt
Reported 2013-03-25 23:16:55 PDT
RefCountedArray needs a size based constructor
Attachments
Patch (1.63 KB, patch)
2013-03-25 23:23 PDT, Oliver Hunt
no flags
Patch (1.69 KB, patch)
2013-03-26 01:50 PDT, Oliver Hunt
benjamin: review+
Oliver Hunt
Comment 1 2013-03-25 23:23:58 PDT
Benjamin Poulain
Comment 2 2013-03-26 00:25:25 PDT
Comment on attachment 195011 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=195011&action=review > Source/WTF/wtf/RefCountedArray.h:71 > + m_data = (static_cast<Header*>(fastMalloc(Header::size() + sizeof(T) * size)))->payload(); > + Header::fromPayload(m_data)->refCount = 1; > + Header::fromPayload(m_data)->length = size; > + ASSERT(Header::fromPayload(m_data)->length == size); You also need to call VectorTypeOperations::initialize() on the new data. Alternatively, by symmetry with Vector, you could have a reserveInitialCapacity() on RefCountedArray that does not do any initialization.
Oliver Hunt
Comment 3 2013-03-26 01:50:46 PDT
Benjamin Poulain
Comment 4 2013-03-26 13:35:50 PDT
Comment on attachment 195029 [details] Patch LGTM.
Oliver Hunt
Comment 5 2013-03-26 20:52:45 PDT
Note You need to log in before you can comment on or make changes to this bug.