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/identifier.cpp

    r11661 r11684  
    124124}
    125125
    126 UString::Rep *Identifier::add(const char *c)
     126PassRefPtr<UString::Rep> Identifier::add(const char *c)
    127127{
    128128    if (!c)
    129         return &UString::Rep::null;
     129        return pass(&UString::Rep::null);
    130130    int length = strlen(c);
    131131    if (length == 0)
    132         return &UString::Rep::empty;
     132        return pass(&UString::Rep::empty);
    133133   
    134     return *identifierTable().insert<const char *, hash, KJS::equal, convert>(c).first;
     134    return pass(*identifierTable().insert<const char *, hash, KJS::equal, convert>(c).first);
    135135}
    136136
     
    164164}
    165165
    166 UString::Rep *Identifier::add(const UChar *s, int length)
     166PassRefPtr<UString::Rep> Identifier::add(const UChar *s, int length)
    167167{
    168168    if (length == 0)
    169         return &UString::Rep::empty;
     169        return pass(&UString::Rep::empty);
    170170   
    171171    UCharBuffer buf = {s, length};
    172     return *identifierTable().insert<UCharBuffer, hash, KJS::equal, convert>(buf).first;
    173 }
    174 
    175 UString::Rep *Identifier::add(UString::Rep *r)
     172    return pass(*identifierTable().insert<UCharBuffer, hash, KJS::equal, convert>(buf).first);
     173}
     174
     175PassRefPtr<UString::Rep> Identifier::add(UString::Rep *r)
    176176{
    177177    if (r->isIdentifier)
    178         return r;
     178        return pass(r);
    179179
    180180    if (r->len == 0)
    181         return &UString::Rep::empty;
     181        return pass(&UString::Rep::empty);
    182182
    183183    UString::Rep *result = *identifierTable().insert(r).first;
    184184    if (result == r)
    185185        r->isIdentifier = true;
    186     return result;
     186    return pass(result);
    187187}
    188188
Note: See TracChangeset for help on using the changeset viewer.