cvs: ZendEngine2 / zend_API.c zend_API.h
| From: | Marcus Boerger | Date: | Sat, 27 May 2006 19:40:06 +0000 |
| Subject: | cvs: ZendEngine2 / zend_API.c zend_API.h | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4937@lists.php.net to get a copy of this message | ||
helly Sat May 27 19:40:06 2006 UTC
Modified files:
/ZendEngine2 zend_API.c zend_API.h
Log:
- Take care of refcounting in zend_fcall_info_*() functions
- Add docu
# I know it is unpopular to add docu here but i think we should add more
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_API.c?r1=1.367&r2=1.368&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.367 ZendEngine2/zend_API.c:1.368
--- ZendEngine2/zend_API.c:1.367 Sat May 27 19:04:16 2006
+++ ZendEngine2/zend_API.c Sat May 27 19:40:06 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.367 2006/05/27 19:04:16 helly Exp $ */
+/* $Id: zend_API.c,v 1.368 2006/05/27 19:40:06 helly Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -2903,6 +2903,9 @@
zval **arg, ***params;
if (fci->params) {
+ while (fci->param_count) {
+ zval_ptr_dtor(fci->params[--fci->param_count]);
+ }
efree(fci->params);
}
fci->params = NULL;
@@ -2923,6 +2926,7 @@
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(args), (void **) &arg, &pos) == SUCCESS) {
*params++ = arg;
+ (*arg)->refcount++;
zend_hash_move_forward_ex(Z_ARRVAL_P(args), &pos);
}
return SUCCESS;
@@ -2931,11 +2935,13 @@
ZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval
**retval_ptr_ptr, zval *args TSRMLS_DC)
{
- zval *retval;
- int result;
+ zval *retval, ***org_params;
+ int result, org_count;
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(fci, args TSRMLS_CC);
}
result = zend_call_function(fci, fcc TSRMLS_CC);
@@ -2943,8 +2949,10 @@
if (!retval_ptr_ptr && retval) {
zval_ptr_dtor(&retval);
}
- if (args && fci->params) {
- efree(fci->params);
+ if (args) {
+ zend_fcall_info_args(fci, NULL TSRMLS_CC);
+ fci->params = org_params;
+ fci->param_count = org_count;
}
return result;
}
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_API.h?r1=1.245&r2=1.246&diff_format=u
Index: ZendEngine2/zend_API.h
diff -u ZendEngine2/zend_API.h:1.245 ZendEngine2/zend_API.h:1.246
--- ZendEngine2/zend_API.h:1.245 Thu May 25 22:20:13 2006
+++ ZendEngine2/zend_API.h Sat May 27 19:40:06 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.h,v 1.245 2006/05/25 22:20:13 helly Exp $ */
+/* $Id: zend_API.h,v 1.246 2006/05/27 19:40:06 helly Exp $ */
#ifndef ZEND_API_H
#define ZEND_API_H
@@ -653,7 +653,7 @@
BEGIN_EXTERN_C()
ZEND_API extern zend_fcall_info_cache empty_fcall_info_cache;
-/* Build zend_call_info/cache from a zval*
+/** Build zend_call_info/cache from a zval*
*
* Caller is responsible to provide a return value, otherwise the we will crash.
* fci->retval_ptr_ptr = NULL;
@@ -662,7 +662,15 @@
* fci->params = NULL;
*/
ZEND_API int zend_fcall_info_init(zval *callable, zend_fcall_info *fci, zend_fcall_info_cache *fcc
TSRMLS_DC);
+
+/** Set or clear the arguments in the zend_call_info struct taking care of
+ * refcount. If args is NULL and arguments are set then those are cleared.
+ */
ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC);
+
+/** Call a function using information created by zend_fcall_info_init()/args().
+ * If args is given then those replace the arguement info in fci is temporarily.
+ */
ZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval **retval,
zval *args TSRMLS_DC);
ZEND_API int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TSRMLS_DC);