@@ -1755,14 +1755,12 @@ static int zend_ffi_cdata_get_closure(zend_object *obj, zend_class_entry **ce_pt
1755
1755
func -> common .arg_flags [2 ] = 0 ;
1756
1756
func -> common .fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE ;
1757
1757
func -> common .function_name = ZSTR_KNOWN (ZEND_STR_MAGIC_INVOKE );
1758
- func -> common .num_args = func -> common .required_num_args = type -> func .args ? zend_hash_num_elements (type -> func .args ) : 0 ;
1758
+ /* set to 0 to avoid arg_info[] allocation, because all values are passed by value anyway */
1759
+ func -> common .num_args = 0 ;
1760
+ func -> common .required_num_args = type -> func .args ? zend_hash_num_elements (type -> func .args ) : 0 ;
1761
+ func -> common .arg_info = NULL ;
1759
1762
func -> internal_function .handler = ZEND_FN (ffi_trampoline );
1760
1763
1761
- if (func -> common .num_args > MAX_ARG_FLAG_NUM ) {
1762
- func -> common .arg_info = emalloc (sizeof (zend_arg_info ) * func -> common .num_args );
1763
- memset (func -> common .arg_info , 0 , sizeof (zend_arg_info ) * func -> common .num_args );
1764
- }
1765
-
1766
1764
func -> internal_function .reserved [0 ] = type ;
1767
1765
func -> internal_function .reserved [1 ] = * (void * * )cdata -> ptr ;
1768
1766
@@ -2416,9 +2414,6 @@ static ZEND_FUNCTION(ffi_trampoline) /* {{{ */
2416
2414
2417
2415
zend_string_release (EX (func )-> common .function_name );
2418
2416
if (EX (func )-> common .fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE ) {
2419
- if (EX (func )-> common .arg_info ) {
2420
- efree (EX (func )-> common .arg_info );
2421
- }
2422
2417
zend_free_trampoline (EX (func ));
2423
2418
EX (func ) = NULL ;
2424
2419
}
@@ -2476,14 +2471,12 @@ static zend_function *zend_ffi_get_func(zend_object **obj, zend_string *name, co
2476
2471
func -> common .arg_flags [2 ] = 0 ;
2477
2472
func -> common .fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE ;
2478
2473
func -> common .function_name = zend_string_copy (name );
2479
- func -> common .num_args = func -> common .required_num_args = type -> func .args ? zend_hash_num_elements (type -> func .args ) : 0 ;
2474
+ /* set to 0 to avoid arg_info[] allocation, because all values are passed by value anyway */
2475
+ func -> common .num_args = 0 ;
2476
+ func -> common .required_num_args = type -> func .args ? zend_hash_num_elements (type -> func .args ) : 0 ;
2477
+ func -> common .arg_info = NULL ;
2480
2478
func -> internal_function .handler = ZEND_FN (ffi_trampoline );
2481
2479
2482
- if (func -> common .num_args > MAX_ARG_FLAG_NUM ) {
2483
- func -> common .arg_info = emalloc (sizeof (zend_arg_info ) * func -> common .num_args );
2484
- memset (func -> common .arg_info , 0 , sizeof (zend_arg_info ) * func -> common .num_args );
2485
- }
2486
-
2487
2480
func -> internal_function .reserved [0 ] = type ;
2488
2481
func -> internal_function .reserved [1 ] = sym -> addr ;
2489
2482
0 commit comments