Use zend_ast_size consistenly#11955
Conversation
iluuu1994
left a comment
There was a problem hiding this comment.
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.