Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions ext/uri/php_uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,16 +1002,6 @@ zend_object *uri_clone_obj_handler(zend_object *object)
return &new_uri_object->std;
}

ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_implementation_set_object_handlers(zend_class_entry *ce, zend_object_handlers *object_handlers)
{
ce->create_object = uri_create_object_handler;
ce->default_object_handlers = object_handlers;
memcpy(object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
object_handlers->offset = XtOffsetOf(uri_object_t, std);
object_handlers->free_obj = uri_free_obj_handler;
object_handlers->clone_obj = uri_clone_obj_handler;
}

PHPAPI zend_result php_uri_parser_register(const uri_parser_t *uri_parser)
{
zend_string *key = zend_string_init_interned(uri_parser->name, strlen(uri_parser->name), true);
Expand All @@ -1032,10 +1022,20 @@ PHPAPI zend_result php_uri_parser_register(const uri_parser_t *uri_parser)
static PHP_MINIT_FUNCTION(uri)
{
uri_rfc3986_uri_ce = register_class_Uri_Rfc3986_Uri();
php_uri_implementation_set_object_handlers(uri_rfc3986_uri_ce, &uri_rfc3986_uri_object_handlers);
uri_rfc3986_uri_ce->create_object = uri_create_object_handler;
uri_rfc3986_uri_ce->default_object_handlers = &uri_rfc3986_uri_object_handlers;
memcpy(&uri_rfc3986_uri_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
uri_rfc3986_uri_object_handlers.offset = XtOffsetOf(uri_object_t, std);
uri_rfc3986_uri_object_handlers.free_obj = uri_free_obj_handler;
uri_rfc3986_uri_object_handlers.clone_obj = uri_clone_obj_handler;

uri_whatwg_url_ce = register_class_Uri_WhatWg_Url();
php_uri_implementation_set_object_handlers(uri_whatwg_url_ce, &uri_whatwg_uri_object_handlers);
uri_whatwg_url_ce->create_object = uri_create_object_handler;
uri_whatwg_url_ce->default_object_handlers = &uri_whatwg_uri_object_handlers;
memcpy(&uri_whatwg_uri_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
uri_whatwg_uri_object_handlers.offset = XtOffsetOf(uri_object_t, std);
uri_whatwg_uri_object_handlers.free_obj = uri_free_obj_handler;
uri_whatwg_uri_object_handlers.clone_obj = uri_clone_obj_handler;

uri_comparison_mode_ce = register_class_Uri_UriComparisonMode();
uri_exception_ce = register_class_Uri_UriException(zend_ce_exception);
Expand Down
2 changes: 0 additions & 2 deletions ext/uri/php_uri.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,4 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) PHPAPI void php_uri_instantiate_uri(
bool should_throw, bool should_update_this_object, zval *errors_zv
);

ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_implementation_set_object_handlers(zend_class_entry *ce, zend_object_handlers *object_handlers);

#endif