@@ -1776,14 +1776,12 @@ static int zend_ffi_cdata_get_closure(zval *obj, zend_class_entry **ce_ptr, zend
1776
1776
func -> common .arg_flags [2 ] = 0 ;
1777
1777
func -> common .fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE ;
1778
1778
func -> common .function_name = ZSTR_KNOWN (ZEND_STR_MAGIC_INVOKE );
1779
- func -> common .num_args = func -> common .required_num_args = type -> func .args ? zend_hash_num_elements (type -> func .args ) : 0 ;
1779
+ /* set to 0 to avoid arg_info[] allocation, because all values are passed by value anyway */
1780
+ func -> common .num_args = 0 ;
1781
+ func -> common .required_num_args = type -> func .args ? zend_hash_num_elements (type -> func .args ) : 0 ;
1782
+ func -> common .arg_info = NULL ;
1780
1783
func -> internal_function .handler = ZEND_FN (ffi_trampoline );
1781
1784
1782
- if (func -> common .num_args > MAX_ARG_FLAG_NUM ) {
1783
- func -> common .arg_info = emalloc (sizeof (zend_arg_info ) * func -> common .num_args );
1784
- memset (func -> common .arg_info , 0 , sizeof (zend_arg_info ) * func -> common .num_args );
1785
- }
1786
-
1787
1785
func -> internal_function .reserved [0 ] = type ;
1788
1786
func -> internal_function .reserved [1 ] = * (void * * )cdata -> ptr ;
1789
1787
@@ -2447,9 +2445,6 @@ static ZEND_FUNCTION(ffi_trampoline) /* {{{ */
2447
2445
2448
2446
zend_string_release (EX (func )-> common .function_name );
2449
2447
if (EX (func )-> common .fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE ) {
2450
- if (EX (func )-> common .arg_info ) {
2451
- efree (EX (func )-> common .arg_info );
2452
- }
2453
2448
zend_free_trampoline (EX (func ));
2454
2449
EX (func ) = NULL ;
2455
2450
}
@@ -2507,14 +2502,12 @@ static zend_function *zend_ffi_get_func(zend_object **obj, zend_string *name, co
2507
2502
func -> common .arg_flags [2 ] = 0 ;
2508
2503
func -> common .fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE ;
2509
2504
func -> common .function_name = zend_string_copy (name );
2510
- func -> common .num_args = func -> common .required_num_args = type -> func .args ? zend_hash_num_elements (type -> func .args ) : 0 ;
2505
+ /* set to 0 to avoid arg_info[] allocation, because all values are passed by value anyway */
2506
+ func -> common .num_args = 0 ;
2507
+ func -> common .required_num_args = type -> func .args ? zend_hash_num_elements (type -> func .args ) : 0 ;
2508
+ func -> common .arg_info = NULL ;
2511
2509
func -> internal_function .handler = ZEND_FN (ffi_trampoline );
2512
2510
2513
- if (func -> common .num_args > MAX_ARG_FLAG_NUM ) {
2514
- func -> common .arg_info = emalloc (sizeof (zend_arg_info ) * func -> common .num_args );
2515
- memset (func -> common .arg_info , 0 , sizeof (zend_arg_info ) * func -> common .num_args );
2516
- }
2517
-
2518
2511
func -> internal_function .reserved [0 ] = type ;
2519
2512
func -> internal_function .reserved [1 ] = sym -> addr ;
2520
2513
0 commit comments