Changeset 48259 in webkit for trunk/JavaScriptCore/wtf


Ignore:
Timestamp:
Sep 10, 2009, 10:33:51 AM (16 years ago)
Author:
[email protected]
Message:

2009-09-10 Zoltan Horvath <[email protected]>

Reviewed by Darin Adler.

Implement fastDeleteSkippingDestructor for FastAllocBase and fastDeleteAllValues for HashSet
https://bugs.webkit.org/show_bug.cgi?id=25930

FastAllocBase has been extended with fastDeleteSkippingDestructor function which
releases memory without destructor call. fastDeleteAllValues has been implemented
similar as deleteAllValues but it uses fastDelete function to release memory.

  • wtf/FastAllocBase.h: (WTF::fastDeleteSkippingDestructor):
  • wtf/HashSet.h: (WTF::fastDeleteAllValues):

2009-09-10 Zoltan Horvath <[email protected]>

Reviewed by Darin Adler.

Use fastNew and fastDelete instead of operator new and delete for CSSSelector class.
https://bugs.webkit.org/show_bug.cgi?id=25930

Change using of operator new to fastNew and operator delete to
fastDeleteSkippingDestructor for CSSSelector class to avoid mismatched function call.

This change fixes valgrind's 'mismatched free' notification.

  • css/CSSParser.cpp: (WebCore::CSSParser::~CSSParser): (WebCore::CSSParser::createFloatingSelector):
  • css/CSSSelectorList.cpp: (WebCore::CSSSelectorList::adoptSelectorVector):
Location:
trunk/JavaScriptCore/wtf
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/FastAllocBase.h

    r45933 r48259  
    302302    }
    303303
     304    template <typename T>
     305    inline void fastDeleteSkippingDestructor(T* p)
     306    {
     307        if (!p)
     308            return;
     309
     310        fastMallocMatchValidateFree(p, Internal::AllocTypeFastNew);
     311        fastFree(p);
     312    }
     313
    304314    namespace Internal {
    305315        // This is a support template for fastDeleteArray.
     
    398408} // namespace WTF
    399409
    400 // Using WTF::FastAllocBase to avoid using FastAllocBase's explicit qualification by WTF::.
    401410using WTF::FastAllocBase;
     411using WTF::fastDeleteSkippingDestructor;
    402412
    403413#endif // FastAllocBase_h
  • trunk/JavaScriptCore/wtf/HashSet.h

    r45792 r48259  
    3030    template<typename Value, typename HashFunctions, typename Traits>
    3131    void deleteAllValues(const HashSet<Value, HashFunctions, Traits>&);
     32    template<typename Value, typename HashFunctions, typename Traits>
     33    void fastDeleteAllValues(const HashSet<Value, HashFunctions, Traits>&);
    3234
    3335    template<typename T> struct IdentityExtractor;
     
    9294    private:
    9395        friend void deleteAllValues<>(const HashSet&);
     96        friend void fastDeleteAllValues<>(const HashSet&);
    9497
    9598        HashTableType m_impl;
     
    252255        deleteAllValues<typename HashSet<T, U, V>::ValueType>(collection.m_impl);
    253256    }
     257
     258    template<typename ValueType, typename HashTableType>
     259    void fastDeleteAllValues(HashTableType& collection)
     260    {
     261        typedef typename HashTableType::const_iterator iterator;
     262        iterator end = collection.end();
     263        for (iterator it = collection.begin(); it != end; ++it)
     264            fastDelete(*it);
     265    }
     266
     267    template<typename T, typename U, typename V>
     268    inline void fastDeleteAllValues(const HashSet<T, U, V>& collection)
     269    {
     270        fastDeleteAllValues<typename HashSet<T, U, V>::ValueType>(collection.m_impl);
     271    }
    254272   
    255273    template<typename T, typename U, typename V, typename W>
Note: See TracChangeset for help on using the changeset viewer.