mirror of
https://github.com/php/php-src.git
synced 2026-04-29 19:23:22 +02:00
Don't allocate php_curlm_handlers separately
This is always allocated together with the php_curlm structure, there's no point in making it a separate allocation.
This commit is contained in:
@@ -119,7 +119,7 @@ typedef struct {
|
||||
int still_running;
|
||||
CURLM *multi;
|
||||
zend_llist easyh;
|
||||
php_curlm_handlers *handlers;
|
||||
php_curlm_handlers handlers;
|
||||
struct {
|
||||
int no;
|
||||
} err;
|
||||
|
||||
+13
-19
@@ -67,7 +67,6 @@ PHP_FUNCTION(curl_multi_init)
|
||||
object_init_ex(return_value, curl_multi_ce);
|
||||
mh = Z_CURL_MULTI_P(return_value);
|
||||
mh->multi = curl_multi_init();
|
||||
mh->handlers = ecalloc(1, sizeof(php_curlm_handlers));
|
||||
|
||||
zend_llist_init(&mh->easyh, sizeof(zval), _php_curl_multi_cleanup_list, 0);
|
||||
}
|
||||
@@ -370,7 +369,7 @@ static int _php_server_push_callback(CURL *parent_ch, CURL *easy, size_t num_hea
|
||||
php_curl *parent;
|
||||
php_curlm *mh = (php_curlm *)userp;
|
||||
size_t rval = CURL_PUSH_DENY;
|
||||
php_curl_callback *t = mh->handlers->server_push;
|
||||
php_curl_callback *t = mh->handlers.server_push;
|
||||
zval *pz_parent_ch = NULL;
|
||||
zval pz_ch;
|
||||
zval headers;
|
||||
@@ -459,15 +458,15 @@ static int _php_curl_multi_setopt(php_curlm *mh, zend_long option, zval *zvalue,
|
||||
}
|
||||
#if LIBCURL_VERSION_NUM > 0x072D00 /* Available since 7.45.0 */
|
||||
case CURLMOPT_PUSHFUNCTION:
|
||||
if (mh->handlers->server_push == NULL) {
|
||||
mh->handlers->server_push = ecalloc(1, sizeof(php_curl_callback));
|
||||
} else if (!Z_ISUNDEF(mh->handlers->server_push->func_name)) {
|
||||
zval_ptr_dtor(&mh->handlers->server_push->func_name);
|
||||
mh->handlers->server_push->fci_cache = empty_fcall_info_cache;
|
||||
if (mh->handlers.server_push == NULL) {
|
||||
mh->handlers.server_push = ecalloc(1, sizeof(php_curl_callback));
|
||||
} else if (!Z_ISUNDEF(mh->handlers.server_push->func_name)) {
|
||||
zval_ptr_dtor(&mh->handlers.server_push->func_name);
|
||||
mh->handlers.server_push->fci_cache = empty_fcall_info_cache;
|
||||
}
|
||||
|
||||
ZVAL_COPY(&mh->handlers->server_push->func_name, zvalue);
|
||||
mh->handlers->server_push->method = PHP_CURL_USER;
|
||||
ZVAL_COPY(&mh->handlers.server_push->func_name, zvalue);
|
||||
mh->handlers.server_push->method = PHP_CURL_USER;
|
||||
error = curl_multi_setopt(mh->multi, option, _php_server_push_callback);
|
||||
if (error != CURLM_OK) {
|
||||
return 0;
|
||||
@@ -553,12 +552,9 @@ void curl_multi_free_obj(zend_object *object)
|
||||
|
||||
curl_multi_cleanup(mh->multi);
|
||||
zend_llist_clean(&mh->easyh);
|
||||
if (mh->handlers->server_push) {
|
||||
zval_ptr_dtor(&mh->handlers->server_push->func_name);
|
||||
efree(mh->handlers->server_push);
|
||||
}
|
||||
if (mh->handlers) {
|
||||
efree(mh->handlers);
|
||||
if (mh->handlers.server_push) {
|
||||
zval_ptr_dtor(&mh->handlers.server_push->func_name);
|
||||
efree(mh->handlers.server_push);
|
||||
}
|
||||
|
||||
zend_object_std_dtor(&mh->std);
|
||||
@@ -570,10 +566,8 @@ static HashTable *curl_multi_get_gc(zend_object *object, zval **table, int *n)
|
||||
|
||||
zend_get_gc_buffer *gc_buffer = zend_get_gc_buffer_create();
|
||||
|
||||
if (curl_multi->handlers) {
|
||||
if (curl_multi->handlers->server_push) {
|
||||
zend_get_gc_buffer_add_zval(gc_buffer, &curl_multi->handlers->server_push->func_name);
|
||||
}
|
||||
if (curl_multi->handlers.server_push) {
|
||||
zend_get_gc_buffer_add_zval(gc_buffer, &curl_multi->handlers.server_push->func_name);
|
||||
}
|
||||
|
||||
zend_llist_position pos;
|
||||
|
||||
Reference in New Issue
Block a user