Ignore:
Timestamp:
Dec 20, 2005, 12:12:50 PM (19 years ago)
Author:
mjs
Message:

JavaScriptCore:

Reviewed by Darin.

  • fixed a leak in the assignment operator from PassRefPtr to RefPtr
  • kxmlcore/RefPtr.h: (KXMLCore::RefPtr::operator=):
  • fix problem with PassRefPtr that darin spotted - it lacked a copy constructor and therefore was using the default one, which can lead to excess derefs

I fixed this by adding a copy constructor from non-const
reference, and by adding a template pass() function that you have
to use when raw pointer or RefPtr are passed where PassRefPtr is
expected.

  • kjs/identifier.cpp: (KJS::Identifier::add): Changed to have PassRefPtr return type and pass() the results.
  • kjs/identifier.h:
  • kjs/property_map.cpp: (KJS::PropertyMap::addSparseArrayPropertiesToReferenceList): Use pass() where required.
  • kjs/ustring.cpp: (KJS::UString::UString): Use pass() as needed. (KJS::UString::append): ditto (KJS::UString::substr): ditto
  • kjs/ustring.h: (KJS::UString::UString): Use initializer instead of assignment
  • kxmlcore/PassRefPtr.h: (KXMLCore::PassRefPtr::PassRefPtr): Added copy constructor (KXMLCore::pass): new template function to make it convenient to pass a PassRefPtr

WebCore:

Reviewed by Darin.

  • change an assignment to a contructor declaration to build with PassRefPtr leak fix changes
  • ksvg2/svg/SVGTransformableImpl.cpp: (SVGTransformableImpl::parseTransformAttribute):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ustring.cpp

    r11638 r11684  
    200200  r->usedPreCapacity = 0;
    201201  r->preCapacity = 0;
     202
    202203  // steal the single reference this Rep was created with
    203204  return PassRefPtr<Rep>::adopt(r);
     
    229230  r->usedPreCapacity = 0;
    230231  r->preCapacity = 0;
     232
    231233  // steal the single reference this Rep was created with
    232234  return PassRefPtr<Rep>::adopt(r);
     
    458460    x.expandCapacity(aOffset + length);
    459461    memcpy(const_cast<UChar *>(a.data() + aSize), b.data(), bSize * sizeof(UChar));
    460     m_rep = Rep::create(a.m_rep, 0, length);
     462    m_rep = Rep::create(pass(a.m_rep), 0, length);
    461463  } else if (-bOffset == b.usedPreCapacity() && 4 * bSize >= aSize) {
    462464    // - b reaches the beginning of its buffer so it qualifies for shared prepend
     
    466468    y.expandPreCapacity(-bOffset + aSize);
    467469    memcpy(const_cast<UChar *>(b.data() - aSize), a.data(), aSize * sizeof(UChar));
    468     m_rep = Rep::create(b.m_rep, -aSize, length);
     470    m_rep = Rep::create(pass(b.m_rep), -aSize, length);
    469471  } else {
    470472    // a does not qualify for append, and b does not qualify for prepend, gotta make a whole new string
     
    684686    expandCapacity(thisOffset + length);
    685687    memcpy(const_cast<UChar *>(data() + thisSize), t.data(), tSize * sizeof(UChar));
    686     m_rep = Rep::create(m_rep, 0, length);
     688    m_rep = Rep::create(pass(m_rep), 0, length);
    687689  } else {
    688690    // this is shared with someone using more capacity, gotta make a whole new string
     
    725727    for (int i = 0; i < tSize; ++i)
    726728      d[thisSize+i] = t[i];
    727     m_rep = Rep::create(m_rep, 0, length);
     729    m_rep = Rep::create(pass(m_rep), 0, length);
    728730  } else {
    729731    // this is shared with someone using more capacity, gotta make a whole new string
     
    765767    UChar *d = const_cast<UChar *>(data());
    766768    d[length] = c;
    767     m_rep = Rep::create(m_rep, 0, length + 1);
     769    m_rep = Rep::create(pass(m_rep), 0, length + 1);
    768770  } else {
    769771    // this is shared with someone using more capacity, gotta make a whole new string
     
    11211123    return *this;
    11221124
    1123   return UString(Rep::create(m_rep, pos, len));
     1125  return UString(Rep::create(pass(m_rep), pos, len));
    11241126}
    11251127
Note: See TracChangeset for help on using the changeset viewer.