@@ -1349,10 +1349,6 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
1349
1349
zend_fcall_info fci ;
1350
1350
TSRMLS_FETCH_FROM_CTX (ch -> thread_ctx );
1351
1351
1352
- MAKE_STD_ZVAL (zhandle );
1353
- MAKE_STD_ZVAL (zpattern );
1354
- MAKE_STD_ZVAL (zstring );
1355
-
1356
1352
ZVAL_RES (& argv [0 ], ch -> res );
1357
1353
Z_ADDREF (argv [0 ]);
1358
1354
ZVAL_STRING (& argv [1 ], pattern );
@@ -1649,15 +1645,15 @@ static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
1649
1645
*/
1650
1646
static void curl_free_string (void * * string )
1651
1647
{
1652
- efree (* string );
1648
+ efree (( char * ) * string );
1653
1649
}
1654
1650
/* }}} */
1655
1651
1656
1652
/* {{{ curl_free_post
1657
1653
*/
1658
1654
static void curl_free_post (void * * post )
1659
1655
{
1660
- curl_formfree ((struct HttpPost * ) * post );
1656
+ curl_formfree ((struct HttpPost * )* post );
1661
1657
}
1662
1658
/* }}} */
1663
1659
@@ -1713,29 +1709,31 @@ PHP_FUNCTION(curl_version)
1713
1709
1714
1710
/* {{{ alloc_curl_handle
1715
1711
*/
1716
- static void alloc_curl_handle ( php_curl * * ch )
1712
+ static php_curl * alloc_curl_handle ( )
1717
1713
{
1718
- * ch = ecalloc (1 , sizeof (php_curl ));
1719
- ( * ch ) -> to_free = ecalloc (1 , sizeof (struct _php_curl_free ));
1720
- ( * ch ) -> handlers = ecalloc (1 , sizeof (php_curl_handlers ));
1721
- ( * ch ) -> handlers -> write = ecalloc (1 , sizeof (php_curl_write ));
1722
- ( * ch ) -> handlers -> write_header = ecalloc (1 , sizeof (php_curl_write ));
1723
- ( * ch ) -> handlers -> read = ecalloc (1 , sizeof (php_curl_read ));
1724
- ( * ch ) -> handlers -> progress = NULL ;
1714
+ php_curl * ch = ecalloc (1 , sizeof (php_curl ));
1715
+ ch -> to_free = ecalloc (1 , sizeof (struct _php_curl_free ));
1716
+ ch -> handlers = ecalloc (1 , sizeof (php_curl_handlers ));
1717
+ ch -> handlers -> write = ecalloc (1 , sizeof (php_curl_write ));
1718
+ ch -> handlers -> write_header = ecalloc (1 , sizeof (php_curl_write ));
1719
+ ch -> handlers -> read = ecalloc (1 , sizeof (php_curl_read ));
1720
+ ch -> handlers -> progress = NULL ;
1725
1721
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
1726
- ( * ch ) -> handlers -> fnmatch = NULL ;
1722
+ ch -> handlers -> fnmatch = NULL ;
1727
1723
#endif
1728
1724
1729
- (* ch )-> header .str_len = 0 ;
1725
+ ch -> header .str_len = 0 ;
1726
+
1727
+ memset (& ch -> err , 0 , sizeof (struct _php_curl_error ));
1730
1728
1731
- memset (& (* ch )-> err , 0 , sizeof (struct _php_curl_error ));
1729
+ zend_llist_init (& ch -> to_free -> str , sizeof (char * ), curl_free_string , 0 );
1730
+ zend_llist_init (& ch -> to_free -> post , sizeof (struct HttpPost ), curl_free_post , 0 );
1731
+ ch -> safe_upload = 1 ; /* for now, for BC reason we allow unsafe API */
1732
1732
1733
- zend_llist_init (& (* ch )-> to_free -> str , sizeof (char * ), (llist_dtor_func_t ) curl_free_string , 0 );
1734
- zend_llist_init (& (* ch )-> to_free -> post , sizeof (struct HttpPost ), (llist_dtor_func_t ) curl_free_post , 0 );
1735
- (* ch )-> safe_upload = 1 ; /* for now, for BC reason we allow unsafe API */
1733
+ ch -> to_free -> slist = emalloc (sizeof (HashTable ));
1734
+ zend_hash_init (ch -> to_free -> slist , 4 , NULL , curl_free_slist , 0 );
1736
1735
1737
- (* ch )-> to_free -> slist = emalloc (sizeof (HashTable ));
1738
- zend_hash_init ((* ch )-> to_free -> slist , 4 , NULL , curl_free_slist , 0 );
1736
+ return ch ;
1739
1737
}
1740
1738
/* }}} */
1741
1739
@@ -1867,7 +1865,7 @@ PHP_FUNCTION(curl_init)
1867
1865
RETURN_FALSE ;
1868
1866
}
1869
1867
1870
- alloc_curl_handle (& ch );
1868
+ ch = alloc_curl_handle ();
1871
1869
TSRMLS_SET_CTX (ch -> thread_ctx );
1872
1870
1873
1871
ch -> cp = cp ;
@@ -1910,7 +1908,7 @@ PHP_FUNCTION(curl_copy_handle)
1910
1908
RETURN_FALSE ;
1911
1909
}
1912
1910
1913
- alloc_curl_handle (& dupch );
1911
+ dupch = alloc_curl_handle ();
1914
1912
TSRMLS_SET_CTX (dupch -> thread_ctx );
1915
1913
1916
1914
dupch -> cp = cp ;
@@ -1970,7 +1968,7 @@ PHP_FUNCTION(curl_copy_handle)
1970
1968
if (ch -> handlers -> fnmatch ) {
1971
1969
dupch -> handlers -> fnmatch = ecalloc (1 , sizeof (php_curl_fnmatch ));
1972
1970
if (!Z_ISUNDEF (ch -> handlers -> fnmatch -> func_name )) {
1973
- ZVAL_COPY (& dupch -> handlers -> fnmatch -> func_name , ch -> handlers -> fnmatch -> func_name );
1971
+ ZVAL_COPY (& dupch -> handlers -> fnmatch -> func_name , & ch -> handlers -> fnmatch -> func_name );
1974
1972
}
1975
1973
dupch -> handlers -> fnmatch -> method = ch -> handlers -> fnmatch -> method ;
1976
1974
curl_easy_setopt (dupch -> cp , CURLOPT_FNMATCH_DATA , (void * ) dupch );
@@ -2660,7 +2658,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
2660
2658
#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
2661
2659
case CURLOPT_POSTREDIR :
2662
2660
convert_to_long_ex (zvalue );
2663
- error = curl_easy_setopt (ch -> cp , CURLOPT_POSTREDIR , Z_LVAL_PP (zvalue ) & CURL_REDIR_POST_ALL );
2661
+ error = curl_easy_setopt (ch -> cp , CURLOPT_POSTREDIR , Z_LVAL_P (zvalue ) & CURL_REDIR_POST_ALL );
2664
2662
break ;
2665
2663
#endif
2666
2664
@@ -3169,7 +3167,7 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
3169
3167
curl_easy_cleanup (ch -> cp );
3170
3168
3171
3169
/* cURL destructors should be invoked only by last curl handle */
3172
- if (Z_REFCOUNTED (ch -> clone ) && Z_REFCOUNT ( ch -> clone ) <= 1 ) {
3170
+ if (Z_ISUNDEF (ch -> clone )) {
3173
3171
zend_llist_clean (& ch -> to_free -> str );
3174
3172
zend_llist_clean (& ch -> to_free -> post );
3175
3173
zend_hash_destroy (ch -> to_free -> slist );
0 commit comments