Skip to content

Clean up the implementation of Randomizer::__construct() #9222

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
Aug 2, 2022

Conversation

TimWolla
Copy link
Member

@TimWolla TimWolla commented Aug 1, 2022

Instead of manually checking whether the constructor was already called, we rely on the readonly modifier of the $engine property.

Additionally use object_init_ex() instead of manually calling ->create_object().


I'm not at all sure that the implementation is correct, but it passes the tests locally both with Zend MM and valgrind.

Instead of manually checking whether the constructor was already called, we
rely on the `readonly` modifier of the `$engine` property.

Additionally use `object_init_ex()` instead of manually calling
`->create_object()`.

ZVAL_OBJ(&zengine_object, engine_object);
OBJ_RELEASE(Z_OBJ_P(&engine));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be zval_ptr_dtor() instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OBJ_RELEASE is fine IMHO, as it prevents some indirection which would boils down to the same code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about it, but from what I've read, OBJ_RELEASE should be fine.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TimWolla TimWolla merged commit a6922fd into php:master Aug 2, 2022
@TimWolla TimWolla deleted the random-randomizer-construct-twice branch August 30, 2022 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants