Skip to content

Commit 4c75901

Browse files
committed
Mark the value param with const modifier in the ext/uri write handler
1 parent 65ad51c commit 4c75901

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

ext/uri/php_uri_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ typedef enum php_uri_component_read_mode {
4545

4646
typedef zend_result (*php_uri_property_handler_read)(void *uri, php_uri_component_read_mode read_mode, zval *retval);
4747

48-
typedef zend_result (*php_uri_property_handler_write)(void *uri, zval *value, zval *errors);
48+
typedef zend_result (*php_uri_property_handler_write)(void *uri, const zval *value, zval *errors);
4949

5050
typedef enum php_uri_property_name {
5151
PHP_URI_PROPERTY_NAME_SCHEME,

ext/uri/uri_parser_rfc3986.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_scheme_read(voi
153153
return SUCCESS;
154154
}
155155

156-
static zend_result php_uri_parser_rfc3986_scheme_write(void *uri, zval *value, zval *errors)
156+
static zend_result php_uri_parser_rfc3986_scheme_write(void *uri, const zval *value, zval *errors)
157157
{
158158
UriUriA *uriparser_uri = get_uri_for_writing(uri);
159159
int result;
@@ -305,7 +305,7 @@ ZEND_ATTRIBUTE_NONNULL void php_uri_parser_rfc3986_host_type_read(php_uri_parser
305305
ZVAL_OBJ_COPY(retval, zend_enum_get_case_cstr(php_uri_ce_rfc3986_uri_host_type, type));
306306
}
307307

308-
static zend_result php_uri_parser_rfc3986_host_write(void *uri, zval *value, zval *errors)
308+
static zend_result php_uri_parser_rfc3986_host_write(void *uri, const zval *value, zval *errors)
309309
{
310310
UriUriA *uriparser_uri = get_uri_for_writing(uri);
311311
int result;
@@ -366,7 +366,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_port_read(void
366366
return SUCCESS;
367367
}
368368

369-
static zend_result php_uri_parser_rfc3986_port_write(void *uri, zval *value, zval *errors)
369+
static zend_result php_uri_parser_rfc3986_port_write(void *uri, const zval *value, zval *errors)
370370
{
371371
UriUriA *uriparser_uri = get_uri_for_writing(uri);
372372
int result;
@@ -439,7 +439,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_path_read(void
439439
return SUCCESS;
440440
}
441441

442-
static zend_result php_uri_parser_rfc3986_path_write(void *uri, zval *value, zval *errors)
442+
static zend_result php_uri_parser_rfc3986_path_write(void *uri, const zval *value, zval *errors)
443443
{
444444
UriUriA *uriparser_uri = get_uri_for_writing(uri);
445445
int result;
@@ -476,7 +476,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_query_read(void
476476
return SUCCESS;
477477
}
478478

479-
static zend_result php_uri_parser_rfc3986_query_write(void *uri, zval *value, zval *errors)
479+
static zend_result php_uri_parser_rfc3986_query_write(void *uri, const zval *value, zval *errors)
480480
{
481481
UriUriA *uriparser_uri = get_uri_for_writing(uri);
482482
int result;
@@ -513,7 +513,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_fragment_read(v
513513
return SUCCESS;
514514
}
515515

516-
static zend_result php_uri_parser_rfc3986_fragment_write(void *uri, zval *value, zval *errors)
516+
static zend_result php_uri_parser_rfc3986_fragment_write(void *uri, const zval *value, zval *errors)
517517
{
518518
UriUriA *uriparser_uri = get_uri_for_writing(uri);
519519
int result;

ext/uri/uri_parser_whatwg.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ZEND_TLS lxb_unicode_idna_t lexbor_idna = {0};
2828

2929
static const size_t lexbor_mraw_byte_size = 8192;
3030

31-
static zend_always_inline void zval_string_or_null_to_lexbor_str(zval *value, lexbor_str_t *lexbor_str)
31+
static zend_always_inline void zval_string_or_null_to_lexbor_str(const zval *value, lexbor_str_t *lexbor_str)
3232
{
3333
if (Z_TYPE_P(value) == IS_STRING && Z_STRLEN_P(value) > 0) {
3434
lexbor_str->data = (lxb_char_t *) Z_STRVAL_P(value);
@@ -40,12 +40,12 @@ static zend_always_inline void zval_string_or_null_to_lexbor_str(zval *value, le
4040
}
4141
}
4242

43-
static zend_always_inline void zval_long_or_null_to_lexbor_str(zval *value, lexbor_str_t *lexbor_str)
43+
static zend_always_inline void zval_long_or_null_to_lexbor_str(const zval *value, lexbor_str_t *lexbor_str)
4444
{
4545
if (Z_TYPE_P(value) == IS_LONG) {
46-
ZVAL_STR(value, zend_long_to_str(Z_LVAL_P(value)));
47-
lexbor_str_init_append(lexbor_str, lexbor_parser.mraw, (const lxb_char_t *) Z_STRVAL_P(value), Z_STRLEN_P(value));
48-
zval_ptr_dtor_str(value);
46+
zend_string *tmp = zend_long_to_str(Z_LVAL_P(value));
47+
lexbor_str_init_append(lexbor_str, lexbor_parser.mraw, (const lxb_char_t *) ZSTR_VAL(tmp), ZSTR_LEN(tmp));
48+
zend_string_release(tmp);
4949
} else {
5050
ZEND_ASSERT(Z_ISNULL_P(value));
5151
lexbor_str->data = (lxb_char_t *) "";
@@ -257,7 +257,7 @@ static zend_result php_uri_parser_whatwg_scheme_read(void *uri, php_uri_componen
257257
return SUCCESS;
258258
}
259259

260-
static zend_result php_uri_parser_whatwg_scheme_write(void *uri, zval *value, zval *errors)
260+
static zend_result php_uri_parser_whatwg_scheme_write(void *uri, const zval *value, zval *errors)
261261
{
262262
lxb_url_t *lexbor_uri = uri;
263263
lexbor_str_t str = {0};
@@ -297,7 +297,7 @@ static zend_result php_uri_parser_whatwg_username_read(void *uri, php_uri_compon
297297
return SUCCESS;
298298
}
299299

300-
static zend_result php_uri_parser_whatwg_username_write(void *uri, zval *value, zval *errors)
300+
static zend_result php_uri_parser_whatwg_username_write(void *uri, const zval *value, zval *errors)
301301
{
302302
lxb_url_t *lexbor_uri = uri;
303303
lexbor_str_t str = {0};
@@ -326,7 +326,7 @@ static zend_result php_uri_parser_whatwg_password_read(void *uri, php_uri_compon
326326
return SUCCESS;
327327
}
328328

329-
static zend_result php_uri_parser_whatwg_password_write(void *uri, zval *value, zval *errors)
329+
static zend_result php_uri_parser_whatwg_password_write(void *uri, const zval *value, zval *errors)
330330
{
331331
lxb_url_t *lexbor_uri = uri;
332332
lexbor_str_t str = {0};
@@ -411,7 +411,7 @@ ZEND_ATTRIBUTE_NONNULL void php_uri_parser_whatwg_host_type_read(const lxb_url_t
411411
}
412412
}
413413

414-
static zend_result php_uri_parser_whatwg_host_write(void *uri, zval *value, zval *errors)
414+
static zend_result php_uri_parser_whatwg_host_write(void *uri, const zval *value, zval *errors)
415415
{
416416
lxb_url_t *lexbor_uri = uri;
417417
lexbor_str_t str = {0};
@@ -440,7 +440,7 @@ static zend_result php_uri_parser_whatwg_port_read(void *uri, php_uri_component_
440440
return SUCCESS;
441441
}
442442

443-
static zend_result php_uri_parser_whatwg_port_write(void *uri, zval *value, zval *errors)
443+
static zend_result php_uri_parser_whatwg_port_write(void *uri, const zval *value, zval *errors)
444444
{
445445
lxb_url_t *lexbor_uri = uri;
446446
lexbor_str_t str = {0};
@@ -469,7 +469,7 @@ static zend_result php_uri_parser_whatwg_path_read(void *uri, php_uri_component_
469469
return SUCCESS;
470470
}
471471

472-
static zend_result php_uri_parser_whatwg_path_write(void *uri, zval *value, zval *errors)
472+
static zend_result php_uri_parser_whatwg_path_write(void *uri, const zval *value, zval *errors)
473473
{
474474
lxb_url_t *lexbor_uri = uri;
475475
lexbor_str_t str = {0};
@@ -498,7 +498,7 @@ static zend_result php_uri_parser_whatwg_query_read(void *uri, php_uri_component
498498
return SUCCESS;
499499
}
500500

501-
static zend_result php_uri_parser_whatwg_query_write(void *uri, zval *value, zval *errors)
501+
static zend_result php_uri_parser_whatwg_query_write(void *uri, const zval *value, zval *errors)
502502
{
503503
lxb_url_t *lexbor_uri = uri;
504504
lexbor_str_t str = {0};
@@ -527,7 +527,7 @@ static zend_result php_uri_parser_whatwg_fragment_read(void *uri, php_uri_compon
527527
return SUCCESS;
528528
}
529529

530-
static zend_result php_uri_parser_whatwg_fragment_write(void *uri, zval *value, zval *errors)
530+
static zend_result php_uri_parser_whatwg_fragment_write(void *uri, const zval *value, zval *errors)
531531
{
532532
lxb_url_t *lexbor_uri = uri;
533533
lexbor_str_t str = {0};

0 commit comments

Comments
 (0)