Commit 65e29c9d authored by oliver@apple.com's avatar oliver@apple.com
Browse files

RefCountedArray needs a size based constructor

https://bugs.webkit.org/show_bug.cgi?id=113277

Reviewed by Benjamin Poulain.

Simple patch to add a size based constructor for RefCountedArray
so that we can create an sharable array without a copy.

* wtf/RefCountedArray.h:
(RefCountedArray):
(WTF::RefCountedArray::RefCountedArray):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146964 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f59fab4e
2013-03-25 Oliver Hunt <oliver@apple.com>
RefCountedArray needs a size based constructor
https://bugs.webkit.org/show_bug.cgi?id=113277
Reviewed by Benjamin Poulain.
Simple patch to add a size based constructor for RefCountedArray
so that we can create an sharable array without a copy.
* wtf/RefCountedArray.h:
(RefCountedArray):
(WTF::RefCountedArray::RefCountedArray):
2013-03-26 James Robinson <jamesr@chromium.org>
 
Compile fix - OS(WINDOWS), not OS(WIN).
......
......@@ -57,7 +57,21 @@ public:
if (m_data)
Header::fromPayload(m_data)->refCount++;
}
explicit RefCountedArray(size_t size)
{
if (!size) {
m_data = 0;
return;
}
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);
VectorTypeOperations<T>::initialize(begin(), end());
}
explicit RefCountedArray(const Vector<T>& other)
{
if (other.isEmpty()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment