1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
--- a/xrange.c 2012/07/28 23:20:09 326859
+++ b/xrange.c 2013/10/06 11:48:38 331707
@@ -175,21 +175,21 @@
zend_class_implements(php_xrange_xri_entry TSRMLS_CC, 1, spl_ce_Countable);
/* Register Class: OddFilterIterator */
- memset(&ce, sizeof(ce), '\0');
+ memset(&ce, 0, sizeof(ce));
INIT_CLASS_ENTRY(ce, PHP_XRANGE_ODDFILTERITERATOR_NAME, php_xrange_OddFilterIterator_functions);
ce.name_length = strlen(PHP_XRANGE_ODDFILTERITERATOR_NAME);
php_xrange_OddFilterIterator_entry =
zend_register_internal_class_ex(&ce, spl_ce_FilterIterator, NULL TSRMLS_CC);
/* Register Class: EvenFilterIterator */
- memset(&ce, sizeof(ce), '\0');
+ memset(&ce, 0, sizeof(ce));
INIT_CLASS_ENTRY(ce, PHP_XRANGE_EVENFILTERITERATOR_NAME, php_xrange_EvenFilterIterator_functions);
ce.name_length = strlen(PHP_XRANGE_EVENFILTERITERATOR_NAME);
php_xrange_EvenFilterIterator_entry =
zend_register_internal_class_ex(&ce, spl_ce_FilterIterator, NULL TSRMLS_CC);
/* Register Class: NumericFilterIterator */
- memset(&ce, sizeof(ce), '\0');
+ memset(&ce, 0, sizeof(ce));
INIT_CLASS_ENTRY(ce, PHP_XRANGE_NUMERICFILTERITERATOR_NAME, php_xrange_NumericFilterIterator_functions);
ce.name_length = strlen(PHP_XRANGE_NUMERICFILTERITERATOR_NAME);
php_xrange_NumericFilterIterator_entry =
@@ -225,13 +225,16 @@
{
if (return_value_used) {
int param_count = ZEND_NUM_ARGS();
+ zval ***params;
+ zval *retval = NULL;
+ zval methodName;
/* because I'm passing the arguments as an array, I'll need to manually
check arg length. */
if (param_count != 2 && param_count != 3) WRONG_PARAM_COUNT;
/* retrieve the function's argument list */
- zval ***params = (zval ***) safe_emalloc(param_count, sizeof(zval*), 0);
+ params = (zval ***) safe_emalloc(param_count, sizeof(zval*), 0);
if (zend_get_parameters_array_ex(param_count, params) == FAILURE) {
efree(params);
WRONG_PARAM_COUNT;
@@ -244,8 +247,6 @@
);
/* setup call to XRangeIterator's constructor (must do manually) */
- zval *retval = NULL;
- zval methodName;
ZVAL_STRING(&methodName, "__construct", 0);
/* pass all arguments through to the XRangeIterator constructor */
@@ -286,6 +287,9 @@
Return a configured range iterator / generator */
PHP_METHOD(PHP_XRANGE_XRI_NAME, __construct)
{
+ xrange_module_storage *internalStorage;
+ double iterations;
+
if (!getThis()) {
php_error_docref(
NULL TSRMLS_CC, E_WARNING, "Don't call the constructor statically"
@@ -293,7 +297,7 @@
RETURN_FALSE;
}
- xrange_module_storage *internalStorage = PHP_XRANGE_ZOS_GET;
+ internalStorage = PHP_XRANGE_ZOS_GET;
/* parse argument list */
internalStorage->step = 1.0; /* default */
@@ -322,7 +326,7 @@
) internalStorage->step *= -1;
/* calculate the total number of iterations before completion */
- double iterations = fabs(
+ iterations = fabs(
(internalStorage->high - internalStorage->low) / internalStorage->step
);
@@ -453,6 +457,7 @@
PHP_METHOD(PHP_XRANGE_ODDFILTERITERATOR_NAME, accept)
{
zval *currentValue;
+ int isOdd;
// method A: bypass getInnerIterator() call
spl_dual_it_object *intern =
@@ -464,7 +469,7 @@
// TODO: method B - use getInnerIterator() w/ compilation option
if (Z_TYPE_P(currentValue) != IS_LONG) convert_to_long(currentValue);
- int isOdd = Z_LVAL_P(currentValue) & 1;
+ isOdd = Z_LVAL_P(currentValue) & 1;
zval_ptr_dtor(¤tValue); /* clean-up */
RETURN_BOOL(isOdd);
@@ -476,6 +481,7 @@
PHP_METHOD(PHP_XRANGE_EVENFILTERITERATOR_NAME, accept)
{
zval *currentValue;
+ int isEven;
/* method A: bypass getInnerIterator() call */
spl_dual_it_object *intern =
@@ -487,7 +493,7 @@
/* TODO: method B - use getInnerIterator() w/ compilation option */
if (Z_TYPE_P(currentValue) != IS_LONG) convert_to_long(currentValue);
- int isEven = !(Z_LVAL_P(currentValue) & 1);
+ isEven = !(Z_LVAL_P(currentValue) & 1);
zval_ptr_dtor(¤tValue); /* clean-up */
RETURN_BOOL(isEven);
@@ -499,6 +505,7 @@
PHP_METHOD(PHP_XRANGE_NUMERICFILTERITERATOR_NAME, accept)
{
zval *currentValue;
+ int isNumeric;
/* method A: bypass getInnerIterator() call */
spl_dual_it_object *intern =
@@ -509,8 +516,6 @@
);
/* TODO: method B - use getInnerIterator() w/ compilation option */
- int isNumeric;
-
/* this code comes from is_numeric() the implementation. it's here to
* to eliminate the overhead of a PHP function call. */
switch (Z_TYPE_P(currentValue)) {
|