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 <zoltan@webkit.org>
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):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@48259
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2009-09-10 Zoltan Horvath <zoltan@webkit.org>
+
+ 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 Laszlo Gombos <laszlo.1.gombos@nokia.com>
Reviewed by Darin Adler.
fastFree(p);
}
+ template <typename T>
+ inline void fastDeleteSkippingDestructor(T* p)
+ {
+ if (!p)
+ return;
+
+ fastMallocMatchValidateFree(p, Internal::AllocTypeFastNew);
+ fastFree(p);
+ }
+
namespace Internal {
// This is a support template for fastDeleteArray.
// This handles the case wherein T has a trivial dtor.
} // namespace WTF
-// Using WTF::FastAllocBase to avoid using FastAllocBase's explicit qualification by WTF::.
using WTF::FastAllocBase;
+using WTF::fastDeleteSkippingDestructor;
#endif // FastAllocBase_h
template<typename Value, typename HashFunctions, typename Traits> class HashSet;
template<typename Value, typename HashFunctions, typename Traits>
void deleteAllValues(const HashSet<Value, HashFunctions, Traits>&);
+ template<typename Value, typename HashFunctions, typename Traits>
+ void fastDeleteAllValues(const HashSet<Value, HashFunctions, Traits>&);
template<typename T> struct IdentityExtractor;
private:
friend void deleteAllValues<>(const HashSet&);
+ friend void fastDeleteAllValues<>(const HashSet&);
HashTableType m_impl;
};
{
deleteAllValues<typename HashSet<T, U, V>::ValueType>(collection.m_impl);
}
+
+ template<typename ValueType, typename HashTableType>
+ void fastDeleteAllValues(HashTableType& collection)
+ {
+ typedef typename HashTableType::const_iterator iterator;
+ iterator end = collection.end();
+ for (iterator it = collection.begin(); it != end; ++it)
+ fastDelete(*it);
+ }
+
+ template<typename T, typename U, typename V>
+ inline void fastDeleteAllValues(const HashSet<T, U, V>& collection)
+ {
+ fastDeleteAllValues<typename HashSet<T, U, V>::ValueType>(collection.m_impl);
+ }
template<typename T, typename U, typename V, typename W>
inline void copyToVector(const HashSet<T, U, V>& collection, W& vector)
+2009-09-10 Zoltan Horvath <zoltan@webkit.org>
+
+ 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):
+
2009-09-10 Steve Block <steveblock@google.com>
Reviewed by Darin Adler.
}
delete m_floatingMediaQueryExp;
delete m_floatingMediaQuery;
- deleteAllValues(m_floatingSelectors);
+ fastDeleteAllValues(m_floatingSelectors);
deleteAllValues(m_floatingValueLists);
deleteAllValues(m_floatingFunctions);
deleteAllValues(m_reusableSelectorVector);
CSSSelector* CSSParser::createFloatingSelector()
{
- CSSSelector* selector = new CSSSelector;
+ CSSSelector* selector = fastNew<CSSSelector>();
m_floatingSelectors.add(selector);
return selector;
}
m_selectorArray = reinterpret_cast<CSSSelector*>(fastMalloc(sizeof(CSSSelector) * selectorVector.size()));
for (size_t i = 0; i < size; ++i) {
memcpy(&m_selectorArray[i], selectorVector[i], sizeof(CSSSelector));
- // We want to free the memory (which was allocated with new), but we
- // don't want the destructor to run since it will affect the copy
- // we've just made. In theory this is undefined, but operator delete
- // is only defined taking a void*, so in practice it should be ok.
- delete reinterpret_cast<char*>(selectorVector[i]);
+ // We want to free the memory (which was allocated with fastNew), but we
+ // don't want the destructor to run since it will affect the copy we've just made.
+ fastDeleteSkippingDestructor(selectorVector[i]);
ASSERT(!m_selectorArray[i].isLastInSelectorList());
}
m_selectorArray[size - 1].setLastInSelectorList();