Skip to content

Commit a720268

Browse files
authored
Use uint32_t for the number of nodes (#11371)
1 parent e8fb0ed commit a720268

File tree

7 files changed

+30
-29
lines changed

7 files changed

+30
-29
lines changed

UPGRADING.INTERNALS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ PHP 8.3 INTERNALS UPGRADE NOTES
134134
the base node of the node list. This function also no longer accepts -1 as the index argument.
135135
- The function dom_namednode_iter() has additional arguments to avoid recomputing the length of
136136
the strings.
137+
- The functions dom_parent_node_prepend(), dom_parent_node_append(), dom_parent_node_after(), and
138+
dom_parent_node_before() now use an uint32_t argument for the number of nodes instead of int.
137139

138140
g. ext/libxml
139141
- Two new functions: php_libxml_invalidate_node_list_cache_from_doc() and

ext/dom/characterdata.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ PHP_METHOD(DOMCharacterData, remove)
364364

365365
PHP_METHOD(DOMCharacterData, after)
366366
{
367-
int argc;
367+
uint32_t argc;
368368
zval *args, *id;
369369
dom_object *intern;
370370
xmlNode *context;
@@ -381,7 +381,7 @@ PHP_METHOD(DOMCharacterData, after)
381381

382382
PHP_METHOD(DOMCharacterData, before)
383383
{
384-
int argc;
384+
uint32_t argc;
385385
zval *args, *id;
386386
dom_object *intern;
387387
xmlNode *context;
@@ -398,7 +398,7 @@ PHP_METHOD(DOMCharacterData, before)
398398

399399
PHP_METHOD(DOMCharacterData, replaceWith)
400400
{
401-
int argc;
401+
uint32_t argc;
402402
zval *args, *id;
403403
dom_object *intern;
404404
xmlNode *context;

ext/dom/document.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,7 +2104,7 @@ Since: DOM Living Standard (DOM4)
21042104
*/
21052105
PHP_METHOD(DOMDocument, append)
21062106
{
2107-
int argc;
2107+
uint32_t argc;
21082108
zval *args, *id;
21092109
dom_object *intern;
21102110
xmlNode *context;
@@ -2125,7 +2125,7 @@ Since: DOM Living Standard (DOM4)
21252125
*/
21262126
PHP_METHOD(DOMDocument, prepend)
21272127
{
2128-
int argc;
2128+
uint32_t argc;
21292129
zval *args, *id;
21302130
dom_object *intern;
21312131
xmlNode *context;

ext/dom/documentfragment.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Since: DOM Living Standard (DOM4)
135135
*/
136136
PHP_METHOD(DOMDocumentFragment, append)
137137
{
138-
int argc;
138+
uint32_t argc;
139139
zval *args, *id;
140140
dom_object *intern;
141141
xmlNode *context;
@@ -156,7 +156,7 @@ Since: DOM Living Standard (DOM4)
156156
*/
157157
PHP_METHOD(DOMDocumentFragment, prepend)
158158
{
159-
int argc;
159+
uint32_t argc;
160160
zval *args, *id;
161161
dom_object *intern;
162162
xmlNode *context;

ext/dom/element.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ PHP_METHOD(DOMElement, remove)
11551155

11561156
PHP_METHOD(DOMElement, after)
11571157
{
1158-
int argc;
1158+
uint32_t argc;
11591159
zval *args, *id;
11601160
dom_object *intern;
11611161
xmlNode *context;
@@ -1172,7 +1172,7 @@ PHP_METHOD(DOMElement, after)
11721172

11731173
PHP_METHOD(DOMElement, before)
11741174
{
1175-
int argc;
1175+
uint32_t argc;
11761176
zval *args, *id;
11771177
dom_object *intern;
11781178
xmlNode *context;
@@ -1192,7 +1192,7 @@ Since: DOM Living Standard (DOM4)
11921192
*/
11931193
PHP_METHOD(DOMElement, append)
11941194
{
1195-
int argc;
1195+
uint32_t argc;
11961196
zval *args, *id;
11971197
dom_object *intern;
11981198
xmlNode *context;
@@ -1213,7 +1213,7 @@ Since: DOM Living Standard (DOM4)
12131213
*/
12141214
PHP_METHOD(DOMElement, prepend)
12151215
{
1216-
int argc;
1216+
uint32_t argc;
12171217
zval *args, *id;
12181218
dom_object *intern;
12191219
xmlNode *context;
@@ -1234,7 +1234,7 @@ Since: DOM Living Standard (DOM4)
12341234
*/
12351235
PHP_METHOD(DOMElement, replaceWith)
12361236
{
1237-
int argc;
1237+
uint32_t argc;
12381238
zval *args, *id;
12391239
dom_object *intern;
12401240
xmlNode *context;

ext/dom/parentnode.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ int dom_parent_node_child_element_count(dom_object *obj, zval *retval)
124124
}
125125
/* }}} */
126126

127-
static bool dom_is_node_in_list(const zval *nodes, int nodesc, const xmlNodePtr node_to_find)
127+
static bool dom_is_node_in_list(const zval *nodes, uint32_t nodesc, const xmlNodePtr node_to_find)
128128
{
129-
for (int i = 0; i < nodesc; i++) {
129+
for (uint32_t i = 0; i < nodesc; i++) {
130130
if (Z_TYPE(nodes[i]) == IS_OBJECT) {
131131
const zend_class_entry *ce = Z_OBJCE(nodes[i]);
132132

@@ -141,9 +141,8 @@ static bool dom_is_node_in_list(const zval *nodes, int nodesc, const xmlNodePtr
141141
return false;
142142
}
143143

144-
xmlNode* dom_zvals_to_fragment(php_libxml_ref_obj *document, xmlNode *contextNode, zval *nodes, int nodesc)
144+
xmlNode* dom_zvals_to_fragment(php_libxml_ref_obj *document, xmlNode *contextNode, zval *nodes, uint32_t nodesc)
145145
{
146-
int i;
147146
xmlDoc *documentNode;
148147
xmlNode *fragment;
149148
xmlNode *newNode;
@@ -170,7 +169,7 @@ xmlNode* dom_zvals_to_fragment(php_libxml_ref_obj *document, xmlNode *contextNod
170169

171170
stricterror = dom_get_strict_error(document);
172171

173-
for (i = 0; i < nodesc; i++) {
172+
for (uint32_t i = 0; i < nodesc; i++) {
174173
if (Z_TYPE(nodes[i]) == IS_OBJECT) {
175174
ce = Z_OBJCE(nodes[i]);
176175

@@ -253,9 +252,9 @@ static void dom_fragment_assign_parent_node(xmlNodePtr parentNode, xmlNodePtr fr
253252
fragment->last = NULL;
254253
}
255254

256-
static zend_result dom_hierarchy_node_list(xmlNodePtr parentNode, zval *nodes, int nodesc)
255+
static zend_result dom_hierarchy_node_list(xmlNodePtr parentNode, zval *nodes, uint32_t nodesc)
257256
{
258-
for (int i = 0; i < nodesc; i++) {
257+
for (uint32_t i = 0; i < nodesc; i++) {
259258
if (Z_TYPE(nodes[i]) == IS_OBJECT) {
260259
const zend_class_entry *ce = Z_OBJCE(nodes[i]);
261260

@@ -270,7 +269,7 @@ static zend_result dom_hierarchy_node_list(xmlNodePtr parentNode, zval *nodes, i
270269
return SUCCESS;
271270
}
272271

273-
void dom_parent_node_append(dom_object *context, zval *nodes, int nodesc)
272+
void dom_parent_node_append(dom_object *context, zval *nodes, uint32_t nodesc)
274273
{
275274
xmlNode *parentNode = dom_object_get_node(context);
276275
xmlNodePtr newchild, prevsib;
@@ -311,7 +310,7 @@ void dom_parent_node_append(dom_object *context, zval *nodes, int nodesc)
311310
xmlFree(fragment);
312311
}
313312

314-
void dom_parent_node_prepend(dom_object *context, zval *nodes, int nodesc)
313+
void dom_parent_node_prepend(dom_object *context, zval *nodes, uint32_t nodesc)
315314
{
316315
xmlNode *parentNode = dom_object_get_node(context);
317316

@@ -379,7 +378,7 @@ static void dom_pre_insert(xmlNodePtr insertion_point, xmlNodePtr parentNode, xm
379378
}
380379
}
381380

382-
void dom_parent_node_after(dom_object *context, zval *nodes, int nodesc)
381+
void dom_parent_node_after(dom_object *context, zval *nodes, uint32_t nodesc)
383382
{
384383
/* Spec link: https://dom.spec.whatwg.org/#dom-childnode-after */
385384

@@ -432,7 +431,7 @@ void dom_parent_node_after(dom_object *context, zval *nodes, int nodesc)
432431
xmlFree(fragment);
433432
}
434433

435-
void dom_parent_node_before(dom_object *context, zval *nodes, int nodesc)
434+
void dom_parent_node_before(dom_object *context, zval *nodes, uint32_t nodesc)
436435
{
437436
/* Spec link: https://dom.spec.whatwg.org/#dom-childnode-before */
438437

@@ -544,7 +543,7 @@ void dom_child_node_remove(dom_object *context)
544543
php_dom_throw_error(NOT_FOUND_ERR, stricterror);
545544
}
546545

547-
void dom_child_replace_with(dom_object *context, zval *nodes, int nodesc)
546+
void dom_child_replace_with(dom_object *context, zval *nodes, uint32_t nodesc)
548547
{
549548
xmlNodePtr child = dom_object_get_node(context);
550549
xmlNodePtr parentNode = child->parent;

ext/dom/php_dom.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ xmlNode *php_dom_libxml_notation_iter(xmlHashTable *ht, int index);
135135
zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, int by_ref);
136136
void dom_set_doc_classmap(php_libxml_ref_obj *document, zend_class_entry *basece, zend_class_entry *ce);
137137

138-
void dom_parent_node_prepend(dom_object *context, zval *nodes, int nodesc);
139-
void dom_parent_node_append(dom_object *context, zval *nodes, int nodesc);
140-
void dom_parent_node_after(dom_object *context, zval *nodes, int nodesc);
141-
void dom_parent_node_before(dom_object *context, zval *nodes, int nodesc);
138+
void dom_parent_node_prepend(dom_object *context, zval *nodes, uint32_t nodesc);
139+
void dom_parent_node_append(dom_object *context, zval *nodes, uint32_t nodesc);
140+
void dom_parent_node_after(dom_object *context, zval *nodes, uint32_t nodesc);
141+
void dom_parent_node_before(dom_object *context, zval *nodes, uint32_t nodesc);
142142
void dom_child_node_remove(dom_object *context);
143-
void dom_child_replace_with(dom_object *context, zval *nodes, int nodesc);
143+
void dom_child_replace_with(dom_object *context, zval *nodes, uint32_t nodesc);
144144

145145
#define DOM_GET_OBJ(__ptr, __id, __prtype, __intern) { \
146146
__intern = Z_DOMOBJ_P(__id); \

0 commit comments

Comments
 (0)