Skip to content

ext/tidy: simplify tidy_instantiate #18647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 25, 2025
Merged
Changes from all commits
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
13 changes: 3 additions & 10 deletions ext/tidy/tidy.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ static zend_string *php_tidy_file_to_mem(const char *, bool);
static void tidy_object_free_storage(zend_object *);
static zend_object *tidy_object_new_node(zend_class_entry *);
static zend_object *tidy_object_new_doc(zend_class_entry *);
static zval *tidy_instantiate(zend_class_entry *, zval *);
static zend_result tidy_doc_cast_handler(zend_object *, zval *, int);
static zend_result tidy_node_cast_handler(zend_object *, zval *, int);
static void tidy_doc_update_properties(PHPTidyObj *);
Expand Down Expand Up @@ -273,7 +272,7 @@ static int _php_tidy_set_tidy_opt(TidyDoc doc, const char *optname, zval *value)

static void tidy_create_node_object(zval *zv, PHPTidyDoc *ptdoc, TidyNode node)
{
tidy_instantiate(tidy_ce_node, zv);
object_init_ex(zv, tidy_ce_node);
PHPTidyObj *newobj = Z_TIDY_P(zv);
newobj->node = node;
newobj->type = is_node;
Expand Down Expand Up @@ -469,12 +468,6 @@ static zend_object *tidy_object_new_doc(zend_class_entry *class_type)
return tidy_object_new(class_type, &tidy_object_handlers_doc, is_doc);
}

static zval *tidy_instantiate(zend_class_entry *pce, zval *object)
{
object_init_ex(object, pce);
return object;
}

static zend_result tidy_doc_cast_handler(zend_object *in, zval *out, int type)
{
TidyBuffer output;
Expand Down Expand Up @@ -1018,7 +1011,7 @@ PHP_FUNCTION(tidy_parse_string)
RETURN_THROWS();
}

tidy_instantiate(tidy_ce_doc, return_value);
object_init_ex(return_value, tidy_ce_doc);
obj = Z_TIDY_P(return_value);

if (php_tidy_apply_config(obj->ptdoc->doc, options_str, options_ht) != SUCCESS
Expand Down Expand Up @@ -1086,7 +1079,7 @@ PHP_FUNCTION(tidy_parse_file)
RETURN_THROWS();
}

tidy_instantiate(tidy_ce_doc, return_value);
object_init_ex(return_value, tidy_ce_doc);
obj = Z_TIDY_P(return_value);

if (php_tidy_apply_config(obj->ptdoc->doc, options_str, options_ht) != SUCCESS
Expand Down