Skip to content

Commit 4a1789c

Browse files
authored
uri: Use PHP_RINIT/SHUTDOWN_FUNCTION in uri_parser_whatwg (php#19541)
This improves discoverability of this kind of “lifecycle” helper function.
1 parent 0cb3f9a commit 4a1789c

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

ext/uri/php_uri.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ static PHP_MSHUTDOWN_FUNCTION(uri)
10771077

10781078
PHP_RINIT_FUNCTION(uri)
10791079
{
1080-
if (lexbor_request_init() == FAILURE) {
1080+
if (PHP_RINIT(uri_parser_whatwg)(INIT_FUNC_ARGS_PASSTHRU) == FAILURE) {
10811081
return FAILURE;
10821082
}
10831083

@@ -1086,7 +1086,9 @@ PHP_RINIT_FUNCTION(uri)
10861086

10871087
PHP_RSHUTDOWN_FUNCTION(uri)
10881088
{
1089-
lexbor_request_shutdown();
1089+
if (PHP_RSHUTDOWN(uri_parser_whatwg)(INIT_FUNC_ARGS_PASSTHRU) == FAILURE) {
1090+
return FAILURE;
1091+
}
10901092

10911093
return SUCCESS;
10921094
}

ext/uri/uri_parser_whatwg.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ static zend_result lexbor_write_fragment(struct uri_internal_t *internal_uri, zv
533533
return SUCCESS;
534534
}
535535

536-
zend_result lexbor_request_init(void)
536+
PHP_RINIT_FUNCTION(uri_parser_whatwg)
537537
{
538538
lexbor_mraw_t *mraw = lexbor_mraw_create();
539539
lxb_status_t status = lexbor_mraw_init(mraw, LEXBOR_MRAW_BYTE_SIZE);
@@ -554,12 +554,14 @@ zend_result lexbor_request_init(void)
554554
return SUCCESS;
555555
}
556556

557-
void lexbor_request_shutdown(void)
557+
PHP_RSHUTDOWN_FUNCTION(uri_parser_whatwg)
558558
{
559559
lxb_url_parser_memory_destroy(&lexbor_parser);
560560
lxb_url_parser_destroy(&lexbor_parser, false);
561561

562562
lexbor_urls = 0;
563+
564+
return SUCCESS;
563565
}
564566

565567
lxb_url_t *lexbor_parse_uri_ex(const char *uri_str, size_t uri_str_len, const lxb_url_t *lexbor_base_url, zval *errors, bool silent)

ext/uri/uri_parser_whatwg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extern const uri_parser_t lexbor_uri_parser;
2424

2525
lxb_url_t *lexbor_parse_uri_ex(const char *uri_str, size_t uri_str_len, const lxb_url_t *lexbor_base_url, zval *errors, bool silent);
2626

27-
zend_result lexbor_request_init(void);
28-
void lexbor_request_shutdown(void);
27+
PHP_RINIT_FUNCTION(uri_parser_whatwg);
28+
PHP_RSHUTDOWN_FUNCTION(uri_parser_whatwg);
2929

3030
#endif

0 commit comments

Comments
 (0)