X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_message.c;h=ae7ca6e9706c16ac80e34c37fded29215329e956;hp=caf9ee82786347b7f4fb491ae928e5d22dc3e995;hb=be9585b914061f84c5d5939673d29ecc048ab1d7;hpb=c01b22de1d6070dcd589cf203de4f002e90eff55 diff --git a/php_http_message.c b/php_http_message.c index caf9ee8..ae7ca6e 100644 --- a/php_http_message.c +++ b/php_http_message.c @@ -604,9 +604,8 @@ static void php_http_message_object_prophandler_set_headers(php_http_message_obj if (Z_TYPE_P(value) != IS_ARRAY && Z_TYPE_P(value) != IS_OBJECT) { convert_to_array_ex(value); - } else { - headers = HASH_OF(value); } + headers = HASH_OF(value); zend_hash_clean(&obj->message->hdrs); array_copy(headers, &obj->message->hdrs); @@ -798,7 +797,7 @@ php_http_message_object_t *php_http_message_object_new_ex(zend_class_entry *ce, { php_http_message_object_t *o; - o = ecalloc(1, sizeof(php_http_message_object_t) + (ce->default_properties_count - 1) * sizeof(zval)); + o = ecalloc(1, sizeof(*o) + zend_object_properties_size(ce)); zend_object_std_init(&o->zo, ce); object_properties_init(&o->zo, ce); @@ -806,8 +805,6 @@ php_http_message_object_t *php_http_message_object_new_ex(zend_class_entry *ce, o->message = msg; if (msg->parent) { o->parent = php_http_message_object_new_ex(ce, msg->parent); - /* not assigned to any zval, so refcount is 0 */ - --GC_REFCOUNT(&o->parent->zo); } o->body = php_http_message_body_object_new_ex(php_http_message_body_class_entry, php_http_message_body_init(&msg->body, NULL)); } @@ -1111,13 +1108,16 @@ static PHP_METHOD(HttpMessage, getHeader) if (!header_ce) { RETURN_ZVAL(header, 1, 1); } else if (instanceof_function(header_ce, php_http_header_class_entry)) { + php_http_object_method_t cb; zval argv[2]; ZVAL_STRINGL(&argv[0], header_str, header_len); ZVAL_COPY(&argv[1], header); object_init_ex(return_value, header_ce); - php_http_method_call(return_value, ZEND_STRL("__construct"), 2, argv, NULL); + php_http_object_method_init(&cb, return_value, ZEND_STRL("__construct")); + php_http_object_method_call(&cb, return_value, NULL, 2, argv); + php_http_object_method_dtor(&cb); zval_ptr_dtor(&argv[0]); zval_ptr_dtor(&argv[1]);