Changeset 39897 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Jan 14, 2009, 11:07:48 AM (16 years ago)
Author:
[email protected]
Message:

2009-01-14 Dean McNamee <[email protected]>

Reviewed by Darin Adler and Oliver hunt.

Correctly match allocation functions by implementing a custom deref().

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

  • runtime/ByteArray.h: (JSC::ByteArray::deref): (JSC::ByteArray::ByteArray):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/ByteArray.h

    r39631 r39897  
    3131
    3232namespace JSC {
    33     class ByteArray : public RefCounted<ByteArray> {
     33    class ByteArray : public WTF::RefCountedBase {
    3434    public:
    3535        unsigned length() const { return m_size; }
     
    5656        unsigned char* data() { return m_data; }
    5757
     58        void deref()
     59        {
     60            if (derefBase()) {
     61                // We allocated with new unsigned char[] in create(),
     62                // and then used placement new to construct the object.
     63                this->~ByteArray();
     64                delete[] reinterpret_cast<unsigned char*>(this);
     65            }
     66        }
     67
    5868        static PassRefPtr<ByteArray> create(size_t size);
    5969
    6070    private:
    6171        ByteArray(size_t size)
    62             : m_size(size)
     72            : RefCountedBase(1)
     73            , m_size(size)
    6374        {
    6475        }
Note: See TracChangeset for help on using the changeset viewer.