summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2010-11-15 17:06:27 +0000
committerFelipe Pena <felipe@php.net>2010-11-15 17:06:27 +0000
commit565c484222e21667dcd55ea78889e06117266f1d (patch)
treee6d518139a936ac586665f1bfe855d97a79bc117 /Zend
parentc3727cc86232eaa7072ed80323fa7f6a3ff30ee4 (diff)
downloadphp-git-565c484222e21667dcd55ea78889e06117266f1d.tar.gz
- Moved leak_variable() to zend_builtin_functions.c (Gustavo)
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_builtin_functions.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index a96c5bc683..07e60e57eb 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -54,6 +54,7 @@ static ZEND_FUNCTION(function_exists);
static ZEND_FUNCTION(class_alias);
#if ZEND_DEBUG
static ZEND_FUNCTION(leak);
+static ZEND_FUNCTION(leak_variable);
#ifdef ZEND_TEST_EXCEPTIONS
static ZEND_FUNCTION(crash);
#endif
@@ -180,6 +181,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_alias, 0, 0, 2)
ZEND_ARG_INFO(0, autoload)
ZEND_END_ARG_INFO()
+#if ZEND_DEBUG
+ZEND_BEGIN_ARG_INFO_EX(arginfo_leak_variable, 0, 0, 1)
+ ZEND_ARG_INFO(0, variable)
+ ZEND_ARG_INFO(0, leak_data)
+ZEND_END_ARG_INFO()
+#endif
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_trigger_error, 0, 0, 1)
ZEND_ARG_INFO(0, message)
ZEND_ARG_INFO(0, error_type)
@@ -245,6 +253,7 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
ZEND_FE(class_alias, arginfo_class_alias)
#if ZEND_DEBUG
ZEND_FE(leak, NULL)
+ ZEND_FE(leak_variable, arginfo_leak_variable)
#ifdef ZEND_TEST_EXCEPTIONS
ZEND_FE(crash, NULL)
#endif
@@ -1367,6 +1376,28 @@ ZEND_FUNCTION(leak)
}
/* }}} */
+/* {{{ proto leak_variable(mixed variable [, bool leak_data]) */
+ZEND_FUNCTION(leak_variable)
+{
+ zval *zv;
+ zend_bool leak_data = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &zv, &leak_data) == FAILURE) {
+ return;
+ }
+
+ if (!leak_data) {
+ zval_add_ref(&zv);
+ } else if (Z_TYPE_P(zv) == IS_RESOURCE) {
+ zend_list_addref(Z_RESVAL_P(zv));
+ } else if (Z_TYPE_P(zv) == IS_OBJECT) {
+ Z_OBJ_HANDLER_P(zv, add_ref)(zv TSRMLS_CC);
+ } else {
+ zend_error(E_WARNING, "Leaking non-zval data is only applicable to resources and objects");
+ }
+}
+/* }}} */
+
#ifdef ZEND_TEST_EXCEPTIONS
ZEND_FUNCTION(crash)