@@ -100,10 +100,12 @@ static int php_get_if_index_from_zval(zval *val, unsigned *out TSRMLS_DC)
100
100
ret = SUCCESS ;
101
101
}
102
102
} else {
103
- zval_add_ref (& val );
104
- convert_to_string_ex (& val );
103
+ if (Z_REFCOUNTED_P (val )) {
104
+ Z_ADDREF_P (val );
105
+ }
106
+ convert_to_string_ex (val );
105
107
ret = php_string_to_if_index (Z_STRVAL_P (val ), out TSRMLS_CC );
106
- zval_ptr_dtor (& val );
108
+ zval_ptr_dtor (val );
107
109
}
108
110
109
111
return ret ;
@@ -114,38 +116,38 @@ static int php_get_if_index_from_zval(zval *val, unsigned *out TSRMLS_DC)
114
116
static int php_get_if_index_from_array (const HashTable * ht , const char * key ,
115
117
php_socket * sock , unsigned int * if_index TSRMLS_DC )
116
118
{
117
- zval * * val ;
119
+ zval * val ;
118
120
119
- if (zend_hash_find ( ht , key , strlen (key ) + 1 , ( void * * ) & val ) == FAILURE ) {
121
+ if (( val = zend_hash_str_find ( ht , key , strlen (key )) ) == NULL ) {
120
122
* if_index = 0 ; /* default: 0 */
121
123
return SUCCESS ;
122
124
}
123
125
124
- return php_get_if_index_from_zval (* val , if_index TSRMLS_CC );
126
+ return php_get_if_index_from_zval (val , if_index TSRMLS_CC );
125
127
}
126
128
127
129
static int php_get_address_from_array (const HashTable * ht , const char * key ,
128
130
php_socket * sock , php_sockaddr_storage * ss , socklen_t * ss_len TSRMLS_DC )
129
131
{
130
- zval * * val ,
131
- * valcp ;
132
+ zval * val ;
132
133
133
- if (zend_hash_find ( ht , key , strlen (key ) + 1 , ( void * * ) & val ) == FAILURE ) {
134
+ if (( val = zend_hash_str_find ( ht , key , strlen (key )) ) == NULL ) {
134
135
php_error_docref (NULL TSRMLS_CC , E_WARNING , "no key \"%s\" passed in optval" , key );
135
136
return FAILURE ;
136
137
}
137
- valcp = * val ;
138
- zval_add_ref (& valcp );
138
+ if (Z_REFCOUNTED_P (val )) {
139
+ Z_ADDREF_P (val );
140
+ }
139
141
convert_to_string_ex (val );
140
- if (!php_set_inet46_addr (ss , ss_len , Z_STRVAL_P (valcp ), sock TSRMLS_CC )) {
141
- zval_ptr_dtor (& valcp );
142
+ if (!php_set_inet46_addr (ss , ss_len , Z_STRVAL_P (val ), sock TSRMLS_CC )) {
143
+ zval_ptr_dtor (val );
142
144
return FAILURE ;
143
145
}
144
- zval_ptr_dtor (& valcp );
146
+ zval_ptr_dtor (val );
145
147
return SUCCESS ;
146
148
}
147
149
148
- static int php_do_mcast_opt (php_socket * php_sock , int level , int optname , zval * * arg4 TSRMLS_DC )
150
+ static int php_do_mcast_opt (php_socket * php_sock , int level , int optname , zval * arg4 TSRMLS_DC )
149
151
{
150
152
HashTable * opt_ht ;
151
153
unsigned int if_index ;
@@ -169,7 +171,7 @@ static int php_do_mcast_opt(php_socket *php_sock, int level, int optname, zval *
169
171
mcast_req_fun = & php_mcast_leave ;
170
172
mcast_req_fun :
171
173
convert_to_array_ex (arg4 );
172
- opt_ht = HASH_OF (* arg4 );
174
+ opt_ht = HASH_OF (arg4 );
173
175
174
176
if (php_get_address_from_array (opt_ht , "group" , php_sock , & group ,
175
177
& glen TSRMLS_CC ) == FAILURE ) {
@@ -205,7 +207,7 @@ static int php_do_mcast_opt(php_socket *php_sock, int level, int optname, zval *
205
207
mcast_sreq_fun = & php_mcast_leave_source ;
206
208
mcast_sreq_fun :
207
209
convert_to_array_ex (arg4 );
208
- opt_ht = HASH_OF (* arg4 );
210
+ opt_ht = HASH_OF (arg4 );
209
211
210
212
if (php_get_address_from_array (opt_ht , "group" , php_sock , & group ,
211
213
& glen TSRMLS_CC ) == FAILURE ) {
@@ -244,7 +246,7 @@ static int php_do_mcast_opt(php_socket *php_sock, int level, int optname, zval *
244
246
int php_do_setsockopt_ip_mcast (php_socket * php_sock ,
245
247
int level ,
246
248
int optname ,
247
- zval * * arg4 TSRMLS_DC )
249
+ zval * arg4 TSRMLS_DC )
248
250
{
249
251
unsigned int if_index ;
250
252
struct in_addr if_addr ;
@@ -269,7 +271,7 @@ int php_do_setsockopt_ip_mcast(php_socket *php_sock,
269
271
}
270
272
271
273
case IP_MULTICAST_IF :
272
- if (php_get_if_index_from_zval (* arg4 , & if_index TSRMLS_CC ) == FAILURE ) {
274
+ if (php_get_if_index_from_zval (arg4 , & if_index TSRMLS_CC ) == FAILURE ) {
273
275
return FAILURE ;
274
276
}
275
277
@@ -282,17 +284,17 @@ int php_do_setsockopt_ip_mcast(php_socket *php_sock,
282
284
283
285
case IP_MULTICAST_LOOP :
284
286
convert_to_boolean_ex (arg4 );
285
- ipv4_mcast_ttl_lback = (unsigned char ) (Z_TYPE_PP (arg4 ) == IS_TRUE );
287
+ ipv4_mcast_ttl_lback = (unsigned char ) (Z_TYPE_P (arg4 ) == IS_TRUE );
286
288
goto ipv4_loop_ttl ;
287
289
288
290
case IP_MULTICAST_TTL :
289
291
convert_to_long_ex (arg4 );
290
- if (Z_LVAL_PP (arg4 ) < 0L || Z_LVAL_PP (arg4 ) > 255L ) {
292
+ if (Z_LVAL_P (arg4 ) < 0L || Z_LVAL_P (arg4 ) > 255L ) {
291
293
php_error_docref (NULL TSRMLS_CC , E_WARNING ,
292
294
"Expected a value between 0 and 255" );
293
295
return FAILURE ;
294
296
}
295
- ipv4_mcast_ttl_lback = (unsigned char ) Z_LVAL_PP (arg4 );
297
+ ipv4_mcast_ttl_lback = (unsigned char ) Z_LVAL_P (arg4 );
296
298
ipv4_loop_ttl :
297
299
opt_ptr = & ipv4_mcast_ttl_lback ;
298
300
optlen = sizeof (ipv4_mcast_ttl_lback );
@@ -314,7 +316,7 @@ int php_do_setsockopt_ip_mcast(php_socket *php_sock,
314
316
int php_do_setsockopt_ipv6_mcast (php_socket * php_sock ,
315
317
int level ,
316
318
int optname ,
317
- zval * * arg4 TSRMLS_DC )
319
+ zval * arg4 TSRMLS_DC )
318
320
{
319
321
unsigned int if_index ;
320
322
void * opt_ptr ;
@@ -338,7 +340,7 @@ int php_do_setsockopt_ipv6_mcast(php_socket *php_sock,
338
340
}
339
341
340
342
case IPV6_MULTICAST_IF :
341
- if (php_get_if_index_from_zval (* arg4 , & if_index TSRMLS_CC ) == FAILURE ) {
343
+ if (php_get_if_index_from_zval (arg4 , & if_index TSRMLS_CC ) == FAILURE ) {
342
344
return FAILURE ;
343
345
}
344
346
@@ -348,16 +350,16 @@ int php_do_setsockopt_ipv6_mcast(php_socket *php_sock,
348
350
349
351
case IPV6_MULTICAST_LOOP :
350
352
convert_to_boolean_ex (arg4 );
351
- ov = (int ) Z_TYPE_PP (arg4 ) == IS_TRUE ;
353
+ ov = (int ) Z_TYPE_P (arg4 ) == IS_TRUE ;
352
354
goto ipv6_loop_hops ;
353
355
case IPV6_MULTICAST_HOPS :
354
356
convert_to_long_ex (arg4 );
355
- if (Z_LVAL_PP (arg4 ) < -1L || Z_LVAL_PP (arg4 ) > 255L ) {
357
+ if (Z_LVAL_P (arg4 ) < -1L || Z_LVAL_P (arg4 ) > 255L ) {
356
358
php_error_docref (NULL TSRMLS_CC , E_WARNING ,
357
359
"Expected a value between -1 and 255" );
358
360
return FAILURE ;
359
361
}
360
- ov = (int ) Z_LVAL_PP (arg4 );
362
+ ov = (int ) Z_LVAL_P (arg4 );
361
363
ipv6_loop_hops :
362
364
opt_ptr = & ov ;
363
365
optlen = sizeof (ov );
0 commit comments