Created
November 4, 2014 23:41
-
-
Save swtaarrs/a9d0808e63c8d2100051 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/hphp/runtime/ext/domdocument/ext_domdocument.cpp b/hphp/runtime/ext/domdocument/ext_domdocument.cpp | |
index fec95c5..6a35725 100644 | |
--- a/hphp/runtime/ext/domdocument/ext_domdocument.cpp | |
+++ b/hphp/runtime/ext/domdocument/ext_domdocument.cpp | |
@@ -1110,14 +1110,32 @@ static xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName) { | |
return ret; | |
} | |
-static void appendOrphan(XmlNodeSet &orphans, xmlNodePtr node) { | |
+/* | |
+ * If node is not nullptr, insert it into the given orphan set, which it must | |
+ * not already be a member of. | |
+ */ | |
+static void appendOrphan(XmlNodeSet& orphans, xmlNodePtr node) { | |
if (node) { | |
assert(orphans.find(node) == orphans.end()); | |
orphans.insert(node); | |
} | |
} | |
-static void removeOrphanIfNeeded(XmlNodeSet &orphans, xmlNodePtr node) { | |
+/* | |
+ * If node is not nullptr, insert it into the given orphan set, which it may | |
+ * already be a member of. | |
+ */ | |
+static void appendOrphanIfNeeded(XmlNodeSet& orphans, xmlNodePtr node) { | |
+ if (node) { | |
+ orphans.insert(node); | |
+ } | |
+} | |
+ | |
+/* | |
+ * If node is not nullptr and is present in the given orphan set, remove it | |
+ * from the set. | |
+ */ | |
+static void removeOrphanIfNeeded(XmlNodeSet& orphans, xmlNodePtr node) { | |
if (node) { | |
orphans.erase(node); | |
} | |
@@ -1206,9 +1224,10 @@ Variant php_dom_create_object(xmlNodePtr obj, Object doc, bool owner) { | |
od->incRefCount(); | |
nodeobj->m_doc = doc; | |
nodeobj->m_node = obj; | |
- if (owner && doc.get()) { | |
- appendOrphan(*Native::data<DOMDocument>(doc.get())->m_orphans, obj); | |
- } | |
+ } | |
+ if (owner && doc.get()) { | |
+ auto& orphans = *Native::data<DOMDocument>(doc.get())->m_orphans; | |
+ appendOrphanIfNeeded(orphans, obj); | |
} | |
return it->second; | |
} | |
diff --git a/hphp/runtime/ext/domdocument/ext_domdocument.h b/hphp/runtime/ext/domdocument/ext_domdocument.h | |
index bfed5bc..1340bf2 100644 | |
--- a/hphp/runtime/ext/domdocument/ext_domdocument.h | |
+++ b/hphp/runtime/ext/domdocument/ext_domdocument.h | |
@@ -136,7 +136,7 @@ public: | |
/////////////////////////////////////////////////////////////////////////////// | |
// class DOMDocument | |
-typedef hphp_hash_set<xmlNodePtr, pointer_hash<xmlNode> > XmlNodeSet; | |
+typedef hphp_hash_set<xmlNodePtr, pointer_hash<xmlNode>> XmlNodeSet; | |
class DOMDocument : public DOMNode { | |
public: | |
@@ -166,7 +166,7 @@ public: | |
bool m_stricterror; | |
bool m_recover; | |
Array m_classmap; | |
- std::auto_ptr<XmlNodeSet> m_orphans; | |
+ std::unique_ptr<XmlNodeSet> m_orphans; | |
bool m_owner; | |
ObjectData* m_self; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment