More OwnPtr work, including making clear set the pointer to 0 before deltion
Created attachment 60669 [details] Patch
Comment on attachment 60669 [details] Patch Glad to see this work continue. Please consider landing this patch in two pieces as described below. JavaScriptCore/wtf/OwnArrayPtr.h:72 + template<typename T> inline void OwnArrayPtr<T>::clear() This change to clear() seems independent of deploying adoptPtr. Why are we doing them in the same patch? It's a bit hard to foresee the consequences of this change. It seems like we'd be better off doing that in a separate patch. WebCore/css/CSSSelector.h:311 + m_data.m_rareData = new RareData(adoptPtr(m_data.m_tagHistory)); This adoptPtr is unfortunately far from the new... Why doesn't the "new RareData" have an adoptPtr?
(In reply to comment #2) > JavaScriptCore/wtf/OwnArrayPtr.h:72 > + template<typename T> inline void OwnArrayPtr<T>::clear() > This change to clear() seems independent of deploying adoptPtr. Why are we doing them in the same patch? It's a bit hard to foresee the consequences of this change. It seems like we'd be better off doing that in a separate patch. Yes, OK. I’ll land these separately. > WebCore/css/CSSSelector.h:311 > + m_data.m_rareData = new RareData(adoptPtr(m_data.m_tagHistory)); > This adoptPtr is unfortunately far from the new... Why doesn't the "new RareData" have an adoptPtr? The answer to both questions is the same. The m_data object is a union and so has raw pointers in it rather than smart pointers. Thus, we need to leak the pointers on the way in, and adopt then pointers on the way out. There are probably multiple ways to refactor this so it's cleaner, but none immediately come to mind.
Committed r62677: <http://trac.webkit.org/changeset/62677>
The clear change is in <http://trac.webkit.org/changeset/62674>.