Skip to content

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()`.
zend_update_property(random_ce_Random_Randomizer, Z_OBJ_P(ZEND_THIS), "engine", strlen("engine"), &engine);

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