summaryrefslogtreecommitdiff
path: root/zend/parametersimpl.h
diff options
context:
space:
mode:
authorMartijn Otto <martijn.otto@copernica.com>2016-05-11 17:34:40 +0200
committerMartijn Otto <martijn.otto@copernica.com>2016-05-11 17:34:40 +0200
commit9f2e816c787c30ceeb139623c8dae594c4b4443d (patch)
treee434ebd2ff37c98bdc5934120b48cda1bf3899c2 /zend/parametersimpl.h
parent570590058d16274005a4994fd8f1046d0eaf7f74 (diff)
Work in progress on PHP7 compatibility
Diffstat (limited to 'zend/parametersimpl.h')
-rw-r--r--zend/parametersimpl.h29
1 files changed, 20 insertions, 9 deletions
diff --git a/zend/parametersimpl.h b/zend/parametersimpl.h
index 2841c75..178f1be 100644
--- a/zend/parametersimpl.h
+++ b/zend/parametersimpl.h
@@ -2,7 +2,7 @@
* ParametersImpl.h
*
* Extended parameters class that can be instantiated
- *
+ *
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2013 Copernica BV
*/
@@ -28,22 +28,33 @@ public:
{
// reserve plenty of space
reserve(argc);
-
+
+ // array to store all the arguments in
+ zval arguments[argc];
+
+ // retrieve the arguments
+ zend_get_parameters_array_ex(argc, arguments);
+
// loop through the arguments
for (int i=0; i<argc; i++)
{
- // get the argument
- zval **arg = (zval **) (zend_vm_stack_top(TSRMLS_C) - 1 - (argc-i));
-
// append value
- emplace_back(*arg);
+ emplace_back(&arguments[i]);
}
}
-
+
/**
- * Destructor
+ * Do _not_ add a virtual destructor here.
+ *
+ * We are extending a vector, which does not itself
+ * have a virtual destructor, so destructing through
+ * a pointer to this vector has no effect.
+ *
+ * By adding a virtual destructor we create a vtable,
+ * which makes the class bigger, causing slicing and
+ * then we are actually introducing the problem that
+ * we are trying to avoid!
*/
- virtual ~ParametersImpl() {}
};
/**