mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Use zend_ast_size consistenly (#11955)
* 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.
This commit is contained in:
committed by
GitHub
parent
e56ed6e1ab
commit
2196e2299f
@@ -313,7 +313,7 @@ typedef void (*zend_ast_apply_func)(zend_ast **ast_ptr, void *context);
|
||||
ZEND_API void zend_ast_apply(zend_ast *ast, zend_ast_apply_func fn, void *context);
|
||||
|
||||
static zend_always_inline size_t zend_ast_size(uint32_t children) {
|
||||
return sizeof(zend_ast) - sizeof(zend_ast *) + sizeof(zend_ast *) * children;
|
||||
return XtOffsetOf(zend_ast, child) + (sizeof(zend_ast *) * children);
|
||||
}
|
||||
|
||||
static zend_always_inline bool zend_ast_is_special(zend_ast *ast) {
|
||||
|
||||
@@ -188,7 +188,7 @@ static zend_ast *zend_persist_ast(zend_ast *ast)
|
||||
node = (zend_ast *) copy;
|
||||
} else {
|
||||
uint32_t children = zend_ast_get_num_children(ast);
|
||||
node = zend_shared_memdup(ast, sizeof(zend_ast) - sizeof(zend_ast *) + sizeof(zend_ast *) * children);
|
||||
node = zend_shared_memdup(ast, zend_ast_size(children));
|
||||
for (i = 0; i < children; i++) {
|
||||
if (node->child[i]) {
|
||||
node->child[i] = zend_persist_ast(node->child[i]);
|
||||
|
||||
@@ -87,7 +87,7 @@ static void zend_persist_ast_calc(zend_ast *ast)
|
||||
}
|
||||
} else {
|
||||
uint32_t children = zend_ast_get_num_children(ast);
|
||||
ADD_SIZE(sizeof(zend_ast) - sizeof(zend_ast *) + sizeof(zend_ast *) * children);
|
||||
ADD_SIZE(zend_ast_size(children));
|
||||
for (i = 0; i < children; i++) {
|
||||
if (ast->child[i]) {
|
||||
zend_persist_ast_calc(ast->child[i]);
|
||||
|
||||
Reference in New Issue
Block a user