X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_message.c;h=0982f06c34b08502c39cc38e5506fa8f68e8bcdc;hp=a885cb58a69cfb87212855760755d5dac019575c;hb=1f37d09e4c7f55cf6f2c3c10ea3ec2424a482671;hpb=0347914eda73287d017c6512dfe870382312299a diff --git a/php_http_message.c b/php_http_message.c index a885cb5..0982f06 100644 --- a/php_http_message.c +++ b/php_http_message.c @@ -86,7 +86,7 @@ php_http_message_t *php_http_message_init_env(php_http_message_t *message, php_h php_http_env_get_response_headers(&message->hdrs); if (php_output_get_level()) { if (php_output_get_status() & PHP_OUTPUT_SENT) { - php_error_docref(NULL, E_WARNING, "Could not fetch response body, output has already been sent at %s:%d", php_output_get_start_filename(TSRMLS_C), php_output_get_start_lineno(TSRMLS_C)); + php_error_docref(NULL, E_WARNING, "Could not fetch response body, output has already been sent at %s:%d", php_output_get_start_filename(), php_output_get_start_lineno()); goto error; } else if (SUCCESS != php_output_get_contents(&tval)) { php_error_docref(NULL, E_WARNING, "Could not fetch response body"); @@ -694,7 +694,7 @@ void php_http_message_object_reverse(zval *zmsg, zval *return_value) efree(objects); } else { - RETURN_ZVAL_FAST(zmsg); + RETURN_ZVAL(zmsg, 1, 0); } } @@ -776,10 +776,11 @@ ZEND_RESULT_CODE php_http_message_object_set_body(php_http_message_object_t *msg } if (msg_obj->message) { php_http_message_body_free(&msg_obj->message->body); - msg_obj->message->body = php_http_message_body_init(&body_obj->body, NULL); + msg_obj->message->body = body_obj->body; } else { - msg_obj->message = php_http_message_init(NULL, 0, php_http_message_body_init(&body_obj->body, NULL)); + msg_obj->message = php_http_message_init(NULL, 0, body_obj->body); } + php_http_message_body_addref(body_obj->body); msg_obj->body = body_obj; return SUCCESS; @@ -817,7 +818,7 @@ php_http_message_object_t *php_http_message_object_new_ex(zend_class_entry *ce, return o; } -zend_object *php_http_message_object_clone(zval *this_ptr TSRMLS_DC) +zend_object *php_http_message_object_clone(zval *this_ptr) { php_http_message_object_t *new_obj = NULL; php_http_message_object_t *old_obj = PHP_HTTP_OBJ(NULL, this_ptr); @@ -843,10 +844,16 @@ void php_http_message_object_free(zend_object *object) o->message = NULL; } if (o->parent) { + if (GC_REFCOUNT(&o->parent->zo) == 1) { + zend_objects_store_del(&o->parent->zo); + } zend_objects_store_del(&o->parent->zo); o->parent = NULL; } if (o->body) { + if (GC_REFCOUNT(&o->body->zo) == 1) { + zend_objects_store_del(&o->body->zo); + } zend_objects_store_del(&o->body->zo); o->body = NULL; } @@ -1079,7 +1086,7 @@ static PHP_METHOD(HttpMessage, setBody) PHP_HTTP_MESSAGE_OBJECT_INIT(obj); php_http_message_object_prophandler_set_body(obj, zbody); } - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_addBody, 0, 0, 1) @@ -1096,7 +1103,7 @@ static PHP_METHOD(HttpMessage, addBody) PHP_HTTP_MESSAGE_OBJECT_INIT(obj); php_http_message_body_to_callback(new_obj->body, (php_http_pass_callback_t) php_http_message_body_append, obj->message->body, 0, 0); } - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getHeader, 0, 0, 1) @@ -1117,7 +1124,7 @@ static PHP_METHOD(HttpMessage, getHeader) if ((header = php_http_message_header(obj->message, header_str, header_len))) { if (!header_ce) { - RETURN_ZVAL_FAST(header); + RETURN_ZVAL(header, 1, 0); } else if (instanceof_function(header_ce, php_http_header_class_entry)) { php_http_object_method_t cb; zval argv[2]; @@ -1180,7 +1187,7 @@ static PHP_METHOD(HttpMessage, setHeader) } efree(name); } - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_setHeaders, 0, 0, 1) @@ -1200,7 +1207,7 @@ static PHP_METHOD(HttpMessage, setHeaders) array_join(Z_ARRVAL_P(new_headers), &obj->message->hdrs, 0, ARRAY_JOIN_PRETTIFY|ARRAY_JOIN_STRONLY); } } - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_addHeader, 0, 0, 2) @@ -1229,7 +1236,7 @@ static PHP_METHOD(HttpMessage, addHeader) } efree(name); } - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_addHeaders, 0, 0, 1) @@ -1248,7 +1255,7 @@ static PHP_METHOD(HttpMessage, addHeaders) array_join(Z_ARRVAL_P(new_headers), &obj->message->hdrs, append, ARRAY_JOIN_STRONLY|ARRAY_JOIN_PRETTIFY); } - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getType, 0, 0, 0) @@ -1278,7 +1285,7 @@ static PHP_METHOD(HttpMessage, setType) php_http_message_set_type(obj->message, type); } - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getInfo, 0, 0, 0) @@ -1333,7 +1340,7 @@ static PHP_METHOD(HttpMessage, setInfo) php_http_message_set_info(obj->message, &inf); php_http_info_dtor(&inf); - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getHttpVersion, 0, 0, 0) @@ -1371,7 +1378,7 @@ static PHP_METHOD(HttpMessage, setHttpVersion) obj->message->http.version = version; - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getResponseCode, 0, 0, 0) @@ -1402,7 +1409,7 @@ static PHP_METHOD(HttpMessage, setResponseCode) zend_bool strict = 1; php_http_message_object_t *obj; - php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|b", &code, &strict), invalid_arg, return); + php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "l|b", &code, &strict), invalid_arg, return); obj = PHP_HTTP_OBJ(NULL, getThis()); PHP_HTTP_MESSAGE_OBJECT_INIT(obj); @@ -1420,7 +1427,7 @@ static PHP_METHOD(HttpMessage, setResponseCode) obj->message->http.info.response.code = code; PTR_SET(obj->message->http.info.response.status, estrdup(php_http_env_get_response_status_for_code(code))); - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getResponseStatus, 0, 0, 0) @@ -1453,7 +1460,7 @@ static PHP_METHOD(HttpMessage, setResponseStatus) size_t status_len; php_http_message_object_t *obj; - php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &status, &status_len), invalid_arg, return); + php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &status, &status_len), invalid_arg, return); obj = PHP_HTTP_OBJ(NULL, getThis()); @@ -1464,7 +1471,7 @@ static PHP_METHOD(HttpMessage, setResponseStatus) } PTR_SET(obj->message->http.info.response.status, estrndup(status, status_len)); - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getRequestMethod, 0, 0, 0) @@ -1515,7 +1522,7 @@ static PHP_METHOD(HttpMessage, setRequestMethod) } PTR_SET(obj->message->http.info.request.method, estrndup(method, method_len)); - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getRequestUrl, 0, 0, 0) @@ -1576,7 +1583,7 @@ static PHP_METHOD(HttpMessage, setRequestUrl) PTR_SET(obj->message->http.info.request.url, url); } - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getParentMessage, 0, 0, 0) @@ -1661,7 +1668,7 @@ static PHP_METHOD(HttpMessage, toCallback) zend_fcall_info_args_clear(&fcd.fci, 1); zval_ptr_dtor(&fcd.fcz); - RETURN_ZVAL_FAST(getThis()); + RETURN_ZVAL(getThis(), 1, 0); } } @@ -1703,7 +1710,7 @@ static PHP_METHOD(HttpMessage, unserialize) obj->message = msg; } else { obj->message = php_http_message_init(NULL, 0, NULL); - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not unserialize http\\Message"); + php_error_docref(NULL, E_ERROR, "Could not unserialize http\\Message"); } } } @@ -1755,7 +1762,7 @@ static PHP_METHOD(HttpMessage, prepend) } php_http_message_object_prepend(getThis(), prepend, top); - RETURN_ZVAL_FAST(getThis()); + RETURN_ZVAL(getThis(), 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_reverse, 0, 0, 0) @@ -1825,7 +1832,7 @@ static PHP_METHOD(HttpMessage, count) { zend_long count_mode = -1; - if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &count_mode)) { + if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &count_mode)) { php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis()); PHP_HTTP_MESSAGE_OBJECT_INIT(obj); @@ -1903,7 +1910,7 @@ static PHP_METHOD(HttpMessage, current) php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis()); if (!Z_ISUNDEF(obj->iterator)) { - RETURN_ZVAL_FAST(&obj->iterator); + RETURN_ZVAL(&obj->iterator, 1, 0); } } }