@@ -29,10 +29,10 @@ static zend_array php_random_class_algos;
29
29
static zend_class_entry * php_random_class_ce ;
30
30
static zend_object_handlers php_random_class_object_handlers ;
31
31
32
- static uint32_t range32 (php_random_class * random_class , zend_object * obj , uint32_t umax ) {
32
+ static uint32_t range32 (php_random_class * random_class , uint32_t umax ) {
33
33
uint32_t result , limit ;
34
34
35
- result = php_random_class_next (random_class , obj );
35
+ result = php_random_class_next (random_class );
36
36
37
37
/* Special case where no modulus is required */
38
38
if (UNEXPECTED (umax == UINT32_MAX )) {
@@ -52,19 +52,19 @@ static uint32_t range32(php_random_class *random_class, zend_object *obj, uint32
52
52
53
53
/* Discard numbers over the limit to avoid modulo bias */
54
54
while (UNEXPECTED (result > limit )) {
55
- result = php_random_class_next (random_class , obj );
55
+ result = php_random_class_next (random_class );
56
56
}
57
57
58
58
return result % umax ;
59
59
}
60
60
61
61
#if ZEND_ULONG_MAX > UINT32_MAX
62
- static uint64_t range64 (php_random_class * random_class , zend_object * obj , uint64_t umax ) {
62
+ static uint64_t range64 (php_random_class * random_class , uint64_t umax ) {
63
63
uint64_t result , limit ;
64
64
65
- result = php_random_class_next (random_class , obj );
65
+ result = php_random_class_next (random_class );
66
66
if (random_class -> algo && random_class -> algo -> bytes == 32 ) {
67
- result = (result << 32 ) | php_random_class_next (random_class , obj );
67
+ result = (result << 32 ) | php_random_class_next (random_class );
68
68
}
69
69
70
70
/* Special case where no modulus is required */
@@ -85,9 +85,9 @@ static uint64_t range64(php_random_class *random_class, zend_object *obj, uint64
85
85
86
86
/* Discard numbers over the limit to avoid modulo bias */
87
87
while (UNEXPECTED (result > limit )) {
88
- result = php_random_class_next (random_class , obj );
88
+ result = php_random_class_next (random_class );
89
89
if (random_class -> algo && random_class -> algo -> bytes == 32 ) {
90
- result = (result << 32 ) | php_random_class_next (random_class , obj );
90
+ result = (result << 32 ) | php_random_class_next (random_class );
91
91
}
92
92
}
93
93
@@ -133,7 +133,7 @@ const php_random_class_algo* php_random_class_algo_find(const zend_string *ident
133
133
/* }}} */
134
134
135
135
/* {{{ */
136
- uint64_t php_random_class_next (php_random_class * random_class , zend_object * obj )
136
+ uint64_t php_random_class_next (php_random_class * random_class )
137
137
{
138
138
zend_long ret ;
139
139
zend_function * function ;
@@ -145,33 +145,33 @@ uint64_t php_random_class_next(php_random_class *random_class, zend_object *obj)
145
145
146
146
/* call user implementation. */
147
147
ZVAL_STRING (& function_name , "next" );
148
- function = zend_hash_find_ptr (& obj -> ce -> function_table , Z_STR (function_name ));
148
+ function = zend_hash_find_ptr (& random_class -> std . ce -> function_table , Z_STR (function_name ));
149
149
zval_ptr_dtor (& function_name );
150
150
151
- zend_call_known_instance_method_with_0_params (function , obj , & retval );
151
+ zend_call_known_instance_method_with_0_params (function , & random_class -> std , & retval );
152
152
ret = Z_LVAL (retval );
153
153
154
154
return (uint64_t ) ret ;
155
155
}
156
156
/* }}} */
157
157
158
158
/* {{{ */
159
- zend_long php_random_class_range (php_random_class * random_class , zend_object * obj , zend_long min , zend_long max )
159
+ zend_long php_random_class_range (php_random_class * random_class , zend_long min , zend_long max )
160
160
{
161
161
zend_ulong umax = max - min ;
162
162
163
163
#if ZEND_ULONG_MAX > UINT32_MAX
164
164
if (umax > UINT32_MAX ) {
165
- return (zend_long ) (range64 (random_class , obj , umax ) + min );
165
+ return (zend_long ) (range64 (random_class , umax ) + min );
166
166
}
167
167
#endif
168
168
169
- return (zend_long ) (range32 (random_class , obj , umax ) + min );
169
+ return (zend_long ) (range32 (random_class , umax ) + min );
170
170
}
171
171
/* }}} */
172
172
173
173
/* {{{ */
174
- void php_random_class_array_data_shuffle (php_random_class * random_class , zend_object * obj , zval * array )
174
+ void php_random_class_array_data_shuffle (php_random_class * random_class , zval * array )
175
175
{
176
176
uint32_t idx , j , n_elems ;
177
177
Bucket * p , temp ;
@@ -200,7 +200,7 @@ void php_random_class_array_data_shuffle(php_random_class *random_class, zend_ob
200
200
}
201
201
}
202
202
while (-- n_left ) {
203
- rnd_idx = php_random_class_range (random_class , obj , 0 , n_left );
203
+ rnd_idx = php_random_class_range (random_class , 0 , n_left );
204
204
if (rnd_idx != n_left ) {
205
205
temp = hash -> arData [n_left ];
206
206
hash -> arData [n_left ] = hash -> arData [rnd_idx ];
@@ -225,7 +225,7 @@ void php_random_class_array_data_shuffle(php_random_class *random_class, zend_ob
225
225
}
226
226
}
227
227
while (-- n_left ) {
228
- rnd_idx = php_random_class_range (random_class , obj , 0 , n_left );
228
+ rnd_idx = php_random_class_range (random_class , 0 , n_left );
229
229
if (rnd_idx != n_left ) {
230
230
temp = hash -> arData [n_left ];
231
231
hash -> arData [n_left ] = hash -> arData [rnd_idx ];
@@ -253,7 +253,7 @@ void php_random_class_array_data_shuffle(php_random_class *random_class, zend_ob
253
253
/* }}} */
254
254
255
255
/* {{{ */
256
- void php_random_class_string_shuffle (php_random_class * random_class , zend_object * obj , char * str , zend_long len )
256
+ void php_random_class_string_shuffle (php_random_class * random_class , char * str , zend_long len )
257
257
{
258
258
zend_long n_elems , rnd_idx , n_left ;
259
259
char temp ;
@@ -266,7 +266,7 @@ void php_random_class_string_shuffle(php_random_class *random_class, zend_object
266
266
n_left = n_elems ;
267
267
268
268
while (-- n_left ) {
269
- rnd_idx = php_random_class_range (random_class , obj , 0 , n_left );
269
+ rnd_idx = php_random_class_range (random_class , 0 , n_left );
270
270
if (rnd_idx != n_left ) {
271
271
temp = str [n_left ];
272
272
str [n_left ] = str [rnd_idx ];
@@ -633,7 +633,7 @@ PHP_METHOD(Random, nextInt)
633
633
634
634
ZEND_PARSE_PARAMETERS_NONE ();
635
635
636
- ret = php_random_class_next (random_class , Z_OBJ_P ( ZEND_THIS ) );
636
+ ret = php_random_class_next (random_class );
637
637
if (random_class -> algo ) {
638
638
if (random_class -> algo -> bytes > sizeof (zend_long )) {
639
639
if (PG (random_class_ignore_generated_size_exceeded )) {
@@ -667,7 +667,7 @@ PHP_METHOD(Random, getInt)
667
667
RETURN_THROWS ();
668
668
}
669
669
670
- RETURN_LONG (php_random_class_range (random_class , Z_OBJ_P ( ZEND_THIS ), min , max ));
670
+ RETURN_LONG (php_random_class_range (random_class , min , max ));
671
671
}
672
672
/* }}} */
673
673
@@ -694,9 +694,9 @@ PHP_METHOD(Random, getBytes)
694
694
ret = zend_string_alloc (size , 0 );
695
695
696
696
while (generated_bytes <= size ) {
697
- buf = php_random_class_next (random_class , Z_OBJ_P ( ZEND_THIS ) );
697
+ buf = php_random_class_next (random_class );
698
698
if (random_class -> algo && random_class -> algo -> bytes == sizeof (uint32_t )) {
699
- buf = (buf << 32 ) | php_random_class_next (random_class , Z_OBJ_P ( ZEND_THIS ) );
699
+ buf = (buf << 32 ) | php_random_class_next (random_class );
700
700
}
701
701
bytes = (uint8_t * ) & buf ;
702
702
for (i = 0 ; i < (sizeof (uint64_t ) / sizeof (uint8_t )); i ++ ) {
@@ -724,7 +724,7 @@ PHP_METHOD(Random, shuffleArray)
724
724
725
725
ZVAL_DUP (return_value , array );
726
726
727
- php_random_class_array_data_shuffle (random_class , Z_OBJ_P ( ZEND_THIS ), return_value );
727
+ php_random_class_array_data_shuffle (random_class , return_value );
728
728
}
729
729
/* }}} */
730
730
@@ -740,7 +740,7 @@ PHP_METHOD(Random, shuffleString)
740
740
741
741
RETVAL_STRINGL (ZSTR_VAL (string ), ZSTR_LEN (string ));
742
742
if (Z_STRLEN_P (return_value ) > 1 ) {
743
- php_random_class_string_shuffle (random_class , Z_OBJ_P ( ZEND_THIS ), Z_STRVAL_P (return_value ), (zend_long ) Z_STRLEN_P (return_value ));
743
+ php_random_class_string_shuffle (random_class , Z_STRVAL_P (return_value ), (zend_long ) Z_STRLEN_P (return_value ));
744
744
}
745
745
}
746
746
/* }}} */
0 commit comments