Skip to content

Commit 9a34b57

Browse files
committed
ext/dom: Use zend_hash_add_new variant when registering classes and properties
1 parent 107ed64 commit 9a34b57

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

ext/dom/php_dom.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static void dom_register_prop_handler(HashTable *prop_handler, char *name, size_
290290
hnd.read_func = read_func;
291291
hnd.write_func = write_func;
292292
str = zend_string_init_interned(name, name_len, 1);
293-
zend_hash_add_mem(prop_handler, str, &hnd, sizeof(dom_prop_handler));
293+
zend_hash_add_new_mem(prop_handler, str, &hnd, sizeof(dom_prop_handler));
294294
zend_string_release_ex(str, 1);
295295
}
296296

@@ -692,7 +692,7 @@ PHP_MINIT_FUNCTION(dom)
692692
dom_register_prop_handler(&dom_node_prop_handlers, "localName", sizeof("localName")-1, dom_node_local_name_read, NULL);
693693
dom_register_prop_handler(&dom_node_prop_handlers, "baseURI", sizeof("baseURI")-1, dom_node_base_uri_read, NULL);
694694
dom_register_prop_handler(&dom_node_prop_handlers, "textContent", sizeof("textContent")-1, dom_node_text_content_read, dom_node_text_content_write);
695-
zend_hash_add_ptr(&classes, dom_node_class_entry->name, &dom_node_prop_handlers);
695+
zend_hash_add_new_ptr(&classes, dom_node_class_entry->name, &dom_node_prop_handlers);
696696

697697
dom_namespace_node_class_entry = register_class_DOMNameSpaceNode();
698698
dom_namespace_node_class_entry->create_object = dom_objects_namespace_node_new;
@@ -708,7 +708,7 @@ PHP_MINIT_FUNCTION(dom)
708708
dom_register_prop_handler(&dom_namespace_node_prop_handlers, "ownerDocument", sizeof("ownerDocument")-1, dom_node_owner_document_read, NULL);
709709
dom_register_prop_handler(&dom_namespace_node_prop_handlers, "parentNode", sizeof("parentNode")-1, dom_node_parent_node_read, NULL);
710710
dom_register_prop_handler(&dom_namespace_node_prop_handlers, "parentElement", sizeof("parentElement")-1, dom_node_parent_element_read, NULL);
711-
zend_hash_add_ptr(&classes, dom_namespace_node_class_entry->name, &dom_namespace_node_prop_handlers);
711+
zend_hash_add_new_ptr(&classes, dom_namespace_node_class_entry->name, &dom_namespace_node_prop_handlers);
712712

713713
dom_documentfragment_class_entry = register_class_DOMDocumentFragment(dom_node_class_entry, dom_parentnode_class_entry);
714714
dom_documentfragment_class_entry->create_object = dom_objects_new;
@@ -719,7 +719,7 @@ PHP_MINIT_FUNCTION(dom)
719719
dom_register_prop_handler(&dom_documentfragment_prop_handlers, "childElementCount", sizeof("childElementCount")-1, dom_parent_node_child_element_count, NULL);
720720

721721
zend_hash_merge(&dom_documentfragment_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
722-
zend_hash_add_ptr(&classes, dom_documentfragment_class_entry->name, &dom_documentfragment_prop_handlers);
722+
zend_hash_add_new_ptr(&classes, dom_documentfragment_class_entry->name, &dom_documentfragment_prop_handlers);
723723

724724
dom_abstract_base_document_class_entry = register_class_DOM_Document(dom_node_class_entry, dom_parentnode_class_entry);
725725
/* No need to set create_object as it's abstract. */
@@ -744,23 +744,23 @@ PHP_MINIT_FUNCTION(dom)
744744
register_nondeprecated_xml_props(&dom_document_prop_handlers);
745745

746746
zend_hash_merge(&dom_document_prop_handlers, &dom_abstract_base_document_prop_handlers, dom_copy_prop_handler, 0);
747-
zend_hash_add_ptr(&classes, dom_document_class_entry->name, &dom_document_prop_handlers);
747+
zend_hash_add_new_ptr(&classes, dom_document_class_entry->name, &dom_document_prop_handlers);
748748

749749
dom_html_document_class_entry = register_class_DOM_HTMLDocument(dom_abstract_base_document_class_entry);
750750
dom_document_class_entry->create_object = dom_objects_new;
751751
zend_hash_init(&dom_html_document_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
752752
dom_register_prop_handler(&dom_html_document_prop_handlers, "encoding", sizeof("encoding")-1, dom_document_encoding_read, dom_html_document_encoding_write);
753753

754754
zend_hash_merge(&dom_html_document_prop_handlers, &dom_abstract_base_document_prop_handlers, dom_copy_prop_handler, 0);
755-
zend_hash_add_ptr(&classes, dom_html_document_class_entry->name, &dom_html_document_prop_handlers);
755+
zend_hash_add_new_ptr(&classes, dom_html_document_class_entry->name, &dom_html_document_prop_handlers);
756756

757757
dom_xml_document_class_entry = register_class_DOM_XMLDocument(dom_abstract_base_document_class_entry);
758758
dom_xml_document_class_entry->create_object = dom_objects_new;
759759
zend_hash_init(&dom_xml_document_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
760760
register_nondeprecated_xml_props(&dom_xml_document_prop_handlers);
761761

762762
zend_hash_merge(&dom_xml_document_prop_handlers, &dom_abstract_base_document_prop_handlers, dom_copy_prop_handler, 0);
763-
zend_hash_add_ptr(&classes, dom_xml_document_class_entry->name, &dom_xml_document_prop_handlers);
763+
zend_hash_add_new_ptr(&classes, dom_xml_document_class_entry->name, &dom_xml_document_prop_handlers);
764764

765765
zend_hash_destroy(&dom_abstract_base_document_prop_handlers);
766766

@@ -771,7 +771,7 @@ PHP_MINIT_FUNCTION(dom)
771771

772772
zend_hash_init(&dom_nodelist_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
773773
dom_register_prop_handler(&dom_nodelist_prop_handlers, "length", sizeof("length")-1, dom_nodelist_length_read, NULL);
774-
zend_hash_add_ptr(&classes, dom_nodelist_class_entry->name, &dom_nodelist_prop_handlers);
774+
zend_hash_add_new_ptr(&classes, dom_nodelist_class_entry->name, &dom_nodelist_prop_handlers);
775775

776776
dom_namednodemap_class_entry = register_class_DOMNamedNodeMap(zend_ce_aggregate, zend_ce_countable);
777777
dom_namednodemap_class_entry->create_object = dom_nnodemap_objects_new;
@@ -780,7 +780,7 @@ PHP_MINIT_FUNCTION(dom)
780780

781781
zend_hash_init(&dom_namednodemap_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
782782
dom_register_prop_handler(&dom_namednodemap_prop_handlers, "length", sizeof("length")-1, dom_namednodemap_length_read, NULL);
783-
zend_hash_add_ptr(&classes, dom_namednodemap_class_entry->name, &dom_namednodemap_prop_handlers);
783+
zend_hash_add_new_ptr(&classes, dom_namednodemap_class_entry->name, &dom_namednodemap_prop_handlers);
784784

785785
dom_characterdata_class_entry = register_class_DOMCharacterData(dom_node_class_entry, dom_childnode_class_entry);
786786
dom_characterdata_class_entry->create_object = dom_objects_new;
@@ -791,7 +791,7 @@ PHP_MINIT_FUNCTION(dom)
791791
dom_register_prop_handler(&dom_characterdata_prop_handlers, "previousElementSibling", sizeof("previousElementSibling")-1, dom_node_previous_element_sibling_read, NULL);
792792
dom_register_prop_handler(&dom_characterdata_prop_handlers, "nextElementSibling", sizeof("nextElementSibling")-1, dom_node_next_element_sibling_read, NULL);
793793
zend_hash_merge(&dom_characterdata_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
794-
zend_hash_add_ptr(&classes, dom_characterdata_class_entry->name, &dom_characterdata_prop_handlers);
794+
zend_hash_add_new_ptr(&classes, dom_characterdata_class_entry->name, &dom_characterdata_prop_handlers);
795795

796796
dom_attr_class_entry = register_class_DOMAttr(dom_node_class_entry);
797797
dom_attr_class_entry->create_object = dom_objects_new;
@@ -803,7 +803,7 @@ PHP_MINIT_FUNCTION(dom)
803803
dom_register_prop_handler(&dom_attr_prop_handlers, "ownerElement", sizeof("ownerElement")-1, dom_attr_owner_element_read, NULL);
804804
dom_register_prop_handler(&dom_attr_prop_handlers, "schemaTypeInfo", sizeof("schemaTypeInfo")-1, dom_attr_schema_type_info_read, NULL);
805805
zend_hash_merge(&dom_attr_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
806-
zend_hash_add_ptr(&classes, dom_attr_class_entry->name, &dom_attr_prop_handlers);
806+
zend_hash_add_new_ptr(&classes, dom_attr_class_entry->name, &dom_attr_prop_handlers);
807807

808808
dom_element_class_entry = register_class_DOMElement(dom_node_class_entry, dom_parentnode_class_entry, dom_childnode_class_entry);
809809
dom_element_class_entry->create_object = dom_objects_new;
@@ -819,23 +819,23 @@ PHP_MINIT_FUNCTION(dom)
819819
dom_register_prop_handler(&dom_element_prop_handlers, "previousElementSibling", sizeof("previousElementSibling")-1, dom_node_previous_element_sibling_read, NULL);
820820
dom_register_prop_handler(&dom_element_prop_handlers, "nextElementSibling", sizeof("nextElementSibling")-1, dom_node_next_element_sibling_read, NULL);
821821
zend_hash_merge(&dom_element_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
822-
zend_hash_add_ptr(&classes, dom_element_class_entry->name, &dom_element_prop_handlers);
822+
zend_hash_add_new_ptr(&classes, dom_element_class_entry->name, &dom_element_prop_handlers);
823823

824824
dom_text_class_entry = register_class_DOMText(dom_characterdata_class_entry);
825825
dom_text_class_entry->create_object = dom_objects_new;
826826

827827
zend_hash_init(&dom_text_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
828828
dom_register_prop_handler(&dom_text_prop_handlers, "wholeText", sizeof("wholeText")-1, dom_text_whole_text_read, NULL);
829829
zend_hash_merge(&dom_text_prop_handlers, &dom_characterdata_prop_handlers, dom_copy_prop_handler, 0);
830-
zend_hash_add_ptr(&classes, dom_text_class_entry->name, &dom_text_prop_handlers);
830+
zend_hash_add_new_ptr(&classes, dom_text_class_entry->name, &dom_text_prop_handlers);
831831

832832
dom_comment_class_entry = register_class_DOMComment(dom_characterdata_class_entry);
833833
dom_comment_class_entry->create_object = dom_objects_new;
834-
zend_hash_add_ptr(&classes, dom_comment_class_entry->name, &dom_characterdata_prop_handlers);
834+
zend_hash_add_new_ptr(&classes, dom_comment_class_entry->name, &dom_characterdata_prop_handlers);
835835

836836
dom_cdatasection_class_entry = register_class_DOMCdataSection(dom_text_class_entry);
837837
dom_cdatasection_class_entry->create_object = dom_objects_new;
838-
zend_hash_add_ptr(&classes, dom_cdatasection_class_entry->name, &dom_text_prop_handlers);
838+
zend_hash_add_new_ptr(&classes, dom_cdatasection_class_entry->name, &dom_text_prop_handlers);
839839

840840
dom_documenttype_class_entry = register_class_DOMDocumentType(dom_node_class_entry);
841841
dom_documenttype_class_entry->create_object = dom_objects_new;
@@ -848,7 +848,7 @@ PHP_MINIT_FUNCTION(dom)
848848
dom_register_prop_handler(&dom_documenttype_prop_handlers, "systemId", sizeof("systemId")-1, dom_documenttype_system_id_read, NULL);
849849
dom_register_prop_handler(&dom_documenttype_prop_handlers, "internalSubset", sizeof("internalSubset")-1, dom_documenttype_internal_subset_read, NULL);
850850
zend_hash_merge(&dom_documenttype_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
851-
zend_hash_add_ptr(&classes, dom_documenttype_class_entry->name, &dom_documenttype_prop_handlers);
851+
zend_hash_add_new_ptr(&classes, dom_documenttype_class_entry->name, &dom_documenttype_prop_handlers);
852852

853853
dom_notation_class_entry = register_class_DOMNotation(dom_node_class_entry);
854854
dom_notation_class_entry->create_object = dom_objects_new;
@@ -857,7 +857,7 @@ PHP_MINIT_FUNCTION(dom)
857857
dom_register_prop_handler(&dom_notation_prop_handlers, "publicId", sizeof("publicId")-1, dom_notation_public_id_read, NULL);
858858
dom_register_prop_handler(&dom_notation_prop_handlers, "systemId", sizeof("systemId")-1, dom_notation_system_id_read, NULL);
859859
zend_hash_merge(&dom_notation_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
860-
zend_hash_add_ptr(&classes, dom_notation_class_entry->name, &dom_notation_prop_handlers);
860+
zend_hash_add_new_ptr(&classes, dom_notation_class_entry->name, &dom_notation_prop_handlers);
861861

862862
dom_entity_class_entry = register_class_DOMEntity(dom_node_class_entry);
863863
dom_entity_class_entry->create_object = dom_objects_new;
@@ -870,11 +870,11 @@ PHP_MINIT_FUNCTION(dom)
870870
dom_register_prop_handler(&dom_entity_prop_handlers, "encoding", sizeof("encoding")-1, dom_entity_encoding_read, NULL);
871871
dom_register_prop_handler(&dom_entity_prop_handlers, "version", sizeof("version")-1, dom_entity_version_read, NULL);
872872
zend_hash_merge(&dom_entity_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
873-
zend_hash_add_ptr(&classes, dom_entity_class_entry->name, &dom_entity_prop_handlers);
873+
zend_hash_add_new_ptr(&classes, dom_entity_class_entry->name, &dom_entity_prop_handlers);
874874

875875
dom_entityreference_class_entry = register_class_DOMEntityReference(dom_node_class_entry);
876876
dom_entityreference_class_entry->create_object = dom_objects_new;
877-
zend_hash_add_ptr(&classes, dom_entityreference_class_entry->name, &dom_node_prop_handlers);
877+
zend_hash_add_new_ptr(&classes, dom_entityreference_class_entry->name, &dom_node_prop_handlers);
878878

879879
dom_processinginstruction_class_entry = register_class_DOMProcessingInstruction(dom_node_class_entry);
880880
dom_processinginstruction_class_entry->create_object = dom_objects_new;
@@ -883,7 +883,7 @@ PHP_MINIT_FUNCTION(dom)
883883
dom_register_prop_handler(&dom_processinginstruction_prop_handlers, "target", sizeof("target")-1, dom_processinginstruction_target_read, NULL);
884884
dom_register_prop_handler(&dom_processinginstruction_prop_handlers, "data", sizeof("data")-1, dom_processinginstruction_data_read, dom_processinginstruction_data_write);
885885
zend_hash_merge(&dom_processinginstruction_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0);
886-
zend_hash_add_ptr(&classes, dom_processinginstruction_class_entry->name, &dom_processinginstruction_prop_handlers);
886+
zend_hash_add_new_ptr(&classes, dom_processinginstruction_class_entry->name, &dom_processinginstruction_prop_handlers);
887887

888888
#ifdef LIBXML_XPATH_ENABLED
889889
memcpy(&dom_xpath_object_handlers, &dom_object_handlers, sizeof(zend_object_handlers));
@@ -897,7 +897,7 @@ PHP_MINIT_FUNCTION(dom)
897897
zend_hash_init(&dom_xpath_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1);
898898
dom_register_prop_handler(&dom_xpath_prop_handlers, "document", sizeof("document")-1, dom_xpath_document_read, NULL);
899899
dom_register_prop_handler(&dom_xpath_prop_handlers, "registerNodeNamespaces", sizeof("registerNodeNamespaces")-1, dom_xpath_register_node_ns_read, dom_xpath_register_node_ns_write);
900-
zend_hash_add_ptr(&classes, dom_xpath_class_entry->name, &dom_xpath_prop_handlers);
900+
zend_hash_add_new_ptr(&classes, dom_xpath_class_entry->name, &dom_xpath_prop_handlers);
901901
#endif
902902

903903
register_php_dom_symbols(module_number);

0 commit comments

Comments
 (0)