}
-ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC)
+ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, int free_mem)
{
- HashPosition pos;
- zval **arg, ***params;
-
if (fci->params) {
while (fci->param_count) {
zval_ptr_dtor(fci->params[--fci->param_count]);
}
- efree(fci->params);
+ if (free_mem) {
+ efree(fci->params);
+ fci->params = NULL;
+ }
}
- fci->params = NULL;
fci->param_count = 0;
+}
+
+ZEND_API void zend_fcall_info_args_save(zend_fcall_info *fci, int *param_count, zval ****params)
+{
+ *param_count = fci->param_count;
+ *params = fci->params;
+ fci->param_count = 0;
+ fci->params = NULL;
+}
+
+ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, int param_count, zval ***params)
+{
+ zend_fcall_info_args_clear(fci, 1);
+ fci->param_count = param_count;
+ fci->params = params;
+}
+
+ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC)
+{
+ HashPosition pos;
+ zval **arg, ***params;
+
+ zend_fcall_info_args_clear(fci, !args);
if (!args) {
return SUCCESS;
fci->params = params = (zval***)safe_emalloc(sizeof(zval**), fci->param_count, 0);
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos);
-
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(args), (void **) &arg, &pos) == SUCCESS) {
*params++ = arg;
(*arg)->refcount++;
fci->retval_ptr_ptr = retval_ptr_ptr ? retval_ptr_ptr : &retval;
if (args) {
- org_params = fci->params;
- org_count = fci->param_count;
+ zend_fcall_info_args_save(fci, &org_count, &org_params);
zend_fcall_info_args(fci, args TSRMLS_CC);
}
result = zend_call_function(fci, fcc TSRMLS_CC);
zval_ptr_dtor(&retval);
}
if (args) {
- zend_fcall_info_args(fci, NULL TSRMLS_CC);
- fci->params = org_params;
- fci->param_count = org_count;
+ zend_fcall_info_args_restore(fci, org_count, org_params);
}
return result;
}