Skip to content

Commit 1f1cd5c

Browse files
committed
ext/libxml: Add some const qualifiers
1 parent e59c7f8 commit 1f1cd5c

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

ext/libxml/libxml.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,11 @@ PHP_LIBXML_API void php_libxml_node_free_list(xmlNodePtr node)
333333
if (curnode->type == XML_ELEMENT_NODE) {
334334
/* This ensures that namespace references in this subtree are defined within this subtree,
335335
* otherwise a use-after-free would be possible when the original namespace holder gets freed. */
336-
php_libxml_node_ptr *ptr = curnode->_private;
336+
const php_libxml_node_ptr *ptr = curnode->_private;
337337

338338
/* Checking in case it runs out of reference */
339339
if (ptr->_private) {
340-
php_libxml_node_object *obj = ptr->_private;
340+
const php_libxml_node_object *obj = ptr->_private;
341341
if (!obj->document || obj->document->class_type < PHP_LIBXML_CLASS_MODERN) {
342342
xmlReconciliateNs(curnode->doc, curnode);
343343
}
@@ -524,7 +524,7 @@ php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc)
524524

525525
/* Check if there's been an external transport protocol with an encoding information */
526526
if (enc == XML_CHAR_ENCODING_NONE) {
527-
php_stream *s = (php_stream *) context;
527+
const php_stream *s = (php_stream *) context;
528528
zend_string *charset = php_libxml_sniff_charset_from_stream(s);
529529
if (charset != NULL) {
530530
enc = xmlParseCharEncoding(ZSTR_VAL(charset));
@@ -934,7 +934,7 @@ PHP_LIBXML_API void php_libxml_shutdown(void)
934934
}
935935
}
936936

937-
PHP_LIBXML_API void php_libxml_switch_context(zval *context, zval *oldcontext)
937+
PHP_LIBXML_API void php_libxml_switch_context(const zval *context, zval *oldcontext)
938938
{
939939
if (oldcontext) {
940940
ZVAL_COPY_VALUE(oldcontext, &LIBXML(stream_context));
@@ -1268,7 +1268,7 @@ int php_libxml_xmlCheckUTF8(const unsigned char *s)
12681268
return 1;
12691269
}
12701270

1271-
zval *php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node export_function)
1271+
zval *php_libxml_register_export(const zend_class_entry *ce, php_libxml_export_node export_function)
12721272
{
12731273
php_libxml_func_handler export_hnd;
12741274

@@ -1284,11 +1284,11 @@ PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object)
12841284
xmlNodePtr node = NULL;
12851285

12861286
if (Z_TYPE_P(object) == IS_OBJECT) {
1287-
zend_class_entry *ce = Z_OBJCE_P(object);
1287+
const zend_class_entry *ce = Z_OBJCE_P(object);
12881288
while (ce->parent != NULL) {
12891289
ce = ce->parent;
12901290
}
1291-
php_libxml_func_handler *export_hnd = zend_hash_find_ptr(&php_libxml_exports, ce->name);
1291+
const php_libxml_func_handler *export_hnd = zend_hash_find_ptr(&php_libxml_exports, ce->name);
12921292
if (export_hnd) {
12931293
node = export_hnd->export_func(object);
12941294
}

ext/libxml/mime_sniff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ PHP_LIBXML_API zend_string *php_libxml_sniff_charset_from_stream(const php_strea
314314
ZEND_HASH_REVERSE_FOREACH_VAL_IND(Z_ARRVAL(s->wrapperdata), header) {
315315
if (Z_TYPE_P(header) == IS_STRING) {
316316
/* If no colon is found in the header, we assume it's the HTTP status line and bail out. */
317-
char *colon = memchr(Z_STRVAL_P(header), ':', Z_STRLEN_P(header));
318-
char *space = memchr(Z_STRVAL_P(header), ' ', Z_STRLEN_P(header));
317+
const char *colon = memchr(Z_STRVAL_P(header), ':', Z_STRLEN_P(header));
318+
const char *space = memchr(Z_STRVAL_P(header), ' ', Z_STRLEN_P(header));
319319
if (colon == NULL || space < colon) {
320320
return NULL;
321321
}

ext/libxml/php_libxml.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ PHP_LIBXML_API unsigned int php_libxml_increment_doc_ref(php_libxml_node_object
196196
PHP_LIBXML_API unsigned int php_libxml_decrement_doc_ref_directly(php_libxml_ref_obj *document);
197197
PHP_LIBXML_API unsigned int php_libxml_decrement_doc_ref(php_libxml_node_object *object);
198198
PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object);
199-
PHP_LIBXML_API zval *php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node export_function);
199+
PHP_LIBXML_API zval *php_libxml_register_export(const zend_class_entry *ce, php_libxml_export_node export_function);
200200
/* When an explicit freeing of node and children is required */
201201
PHP_LIBXML_API void php_libxml_node_free_list(xmlNodePtr node);
202202
PHP_LIBXML_API void php_libxml_node_free_resource(xmlNodePtr node);
@@ -208,7 +208,7 @@ PHP_LIBXML_API void php_libxml_pretend_ctx_error_ex(const char *file, int line,
208208
PHP_LIBXML_API void php_libxml_ctx_error(void *ctx, const char *msg, ...);
209209
PHP_LIBXML_API void php_libxml_error_handler_va(php_libxml_error_level error_type, void *ctx, const char *msg, va_list args);
210210
PHP_LIBXML_API int php_libxml_xmlCheckUTF8(const unsigned char *s);
211-
PHP_LIBXML_API void php_libxml_switch_context(zval *context, zval *oldcontext);
211+
PHP_LIBXML_API void php_libxml_switch_context(const zval *context, zval *oldcontext);
212212
PHP_LIBXML_API void php_libxml_issue_error(int level, const char *msg);
213213
PHP_LIBXML_API bool php_libxml_disable_entity_loader(bool disable);
214214
PHP_LIBXML_API void php_libxml_set_old_ns(xmlDocPtr doc, xmlNsPtr ns);

0 commit comments

Comments
 (0)