-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Use zend_ast_size consistenly #11955
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
Use zend_ast_size consistenly #11955
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok to me otherwise. The XtOffsetOf
is not truly less error prone, as we're still relying on the fact that child
is the last element. In theory this removes padding of zend_ast
from the size, in practice I don't know when there would be padding, or whether that's relevant.
child must be the last element, if it is implemented with either the struct hack, zero length extension or C99 flex array.. using offsetof it will return the same value even if I change the struct definition to use proper c99 flexible arrays instead (this patchset is part of initial work to make using c99 flexible arrays instead of the "struck hack" easier) |
It is better not to use sizeof(struct_with_flexible_array) and instead rely on offsetof(type, member) like most other similar wrappers do.
7248014
to
f06c283
Compare
@crrodriguez What I meant is that with the struct hack, adding a new element after |
Thank you @crrodriguez! |
* opcache: use zend_ast_size helper in zend_persist_ast * opcache: use zend_ast_size helper in zend_persist_ast_calc * Zend: fix zend_ast_size definition It is better not to use sizeof(struct_with_flexible_array) and instead rely on offsetof(type, member) like most other similar wrappers do.
Ths calculations are error prone and subject to change.
THis also fixes zend_ast_size implementation to align with other simlar wrappers.