From 389e280e0bba312ff5ca9981801cc842dad26ec2 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 20 Jan 2006 16:48:12 +0000 Subject: [PATCH] add addref param to RETURN_OBJVAL() etc --- http_message_object.c | 11 +++++------ http_request_object.c | 10 +++++----- http_requestpool_object.c | 2 +- php_http_std_defs.h | 26 +++++++++++++------------- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/http_message_object.c b/http_message_object.c index 00fb3ce..475daf1 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -337,7 +337,7 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type case HTTP_MSG_PROPHASH_PARENT_MESSAGE: case HTTP_MSG_CHILD_PROPHASH_PARENT_MESSAGE: if (msg->parent) { - RETVAL_OBJVAL(obj->parent); + RETVAL_OBJVAL(obj->parent, 1); } else { RETVAL_NULL(); } @@ -632,7 +632,7 @@ PHP_METHOD(HttpMessage, fromString) } } if (ce) { - ZVAL_OBJVAL(return_value, http_message_object_new_ex(ce, msg, NULL)); + RETVAL_OBJVAL(http_message_object_new_ex(ce, msg, NULL), 0); } } } @@ -997,7 +997,7 @@ PHP_METHOD(HttpMessage, getParentMessage) getObject(http_message_object, obj); if (obj->message->parent) { - RETVAL_OBJVAL(obj->parent); + RETVAL_OBJVAL(obj->parent, 1); } else { RETVAL_NULL(); } @@ -1260,7 +1260,7 @@ PHP_METHOD(HttpMessage, detach) zend_hash_copy(&msg->hdrs, &obj->message->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); phpstr_append(&msg->body, PHPSTR_VAL(obj->message), PHPSTR_LEN(obj->message)); - ZVAL_OBJVAL(return_value, http_message_object_new_ex(Z_OBJCE_P(getThis()), msg, NULL)); + RETVAL_OBJVAL(http_message_object_new_ex(Z_OBJCE_P(getThis()), msg, NULL), 0); } /* }}} */ @@ -1361,8 +1361,7 @@ PHP_METHOD(HttpMessage, next) if (itr && itr->parent.handle) { zval *old = obj->iterator; MAKE_STD_ZVAL(obj->iterator); - ZVAL_OBJVAL(obj->iterator, itr->parent); - Z_OBJ_ADDREF_P(obj->iterator); + ZVAL_OBJVAL(obj->iterator, itr->parent, 1); zval_ptr_dtor(&old); } else { zval_ptr_dtor(&obj->iterator); diff --git a/http_request_object.c b/http_request_object.c index 80d802f..e6ed74a 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -603,7 +603,7 @@ STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this zval_ptr_dtor(&resp); MAKE_STD_ZVAL(message); - ZVAL_OBJVAL(message, http_message_object_new_ex(http_message_object_ce, msg, NULL)); + ZVAL_OBJVAL(message, http_message_object_new_ex(http_message_object_ce, msg, NULL), 0); SET_PROP(responseMessage, message); zval_ptr_dtor(&message); @@ -1713,7 +1713,7 @@ PHP_METHOD(HttpRequest, getResponseMessage) SET_EH_THROW_HTTP(); message = GET_PROP(responseMessage); if (Z_TYPE_P(message) == IS_OBJECT) { - RETVAL_OBJECT(message); + RETVAL_OBJECT(message, 1); } else { RETVAL_NULL(); } @@ -1750,7 +1750,7 @@ PHP_METHOD(HttpRequest, getRequestMessage) SET_EH_THROW_HTTP(); if ((msg = http_message_parse(PHPSTR_VAL(&obj->request->conv.request), PHPSTR_LEN(&obj->request->conv.request)))) { - ZVAL_OBJVAL(return_value, http_message_object_new_ex(http_message_object_ce, msg, NULL)); + RETVAL_OBJVAL(http_message_object_new_ex(http_message_object_ce, msg, NULL), 0); } SET_EH_NORMAL(); } @@ -1824,7 +1824,7 @@ PHP_METHOD(HttpRequest, getHistory) SET_EH_THROW_HTTP(); if ((msg = http_message_parse(PHPSTR_VAL(&obj->history), PHPSTR_LEN(&obj->history)))) { - ZVAL_OBJVAL(return_value, http_message_object_new_ex(http_message_object_ce, msg, NULL)); + RETVAL_OBJVAL(http_message_object_new_ex(http_message_object_ce, msg, NULL), 0); } SET_EH_NORMAL(); } @@ -1904,7 +1904,7 @@ PHP_METHOD(HttpRequest, send) } else if (SUCCESS == http_request_object_requesthandler(obj, getThis())) { http_request_exec(obj->request); if (SUCCESS == http_request_object_responsehandler(obj, getThis())) { - RETVAL_OBJECT(GET_PROP(responseMessage)); + RETVAL_OBJECT(GET_PROP(responseMessage), 1); } } diff --git a/http_requestpool_object.c b/http_requestpool_object.c index 65eff18..30bfbde 100644 --- a/http_requestpool_object.c +++ b/http_requestpool_object.c @@ -426,7 +426,7 @@ PHP_METHOD(HttpRequestPool, current) current && obj->iterator.pos != pos++; current = zend_llist_get_next_ex(&obj->pool.handles, &lpos)); if (current) { - RETURN_OBJECT(*current); + RETURN_OBJECT(*current, 1); } } RETURN_NULL(); diff --git a/php_http_std_defs.h b/php_http_std_defs.h index aa4f81e..78a9ae2 100644 --- a/php_http_std_defs.h +++ b/php_http_std_defs.h @@ -60,22 +60,22 @@ typedef int STATUS; #define RETVAL_SUCCESS(v) RETVAL_BOOL(SUCCESS == (v)) #define RETURN_SUCCESS(v) RETURN_BOOL(SUCCESS == (v)) /* return object(values) */ -#define RETVAL_OBJECT(o) \ - RETVAL_OBJVAL((o)->value.obj) -#define RETURN_OBJECT(o) \ - RETVAL_OBJECT(o); \ +#define RETVAL_OBJECT(o, addref) \ + RETVAL_OBJVAL((o)->value.obj, addref) +#define RETURN_OBJECT(o, addref) \ + RETVAL_OBJECT(o, addref); \ return -#define RETVAL_OBJVAL(ov) \ - ZVAL_OBJVAL(return_value, ov) \ - if (Z_OBJ_HT_P(return_value)->add_ref) { \ - Z_OBJ_HT_P(return_value)->add_ref(return_value TSRMLS_CC); \ - } -#define RETURN_OBJVAL(ov) \ - RETVAL_OBJVAL(ov); \ +#define RETVAL_OBJVAL(ov, addref) \ + ZVAL_OBJVAL(return_value, ov, addref) +#define RETURN_OBJVAL(ov, addref) \ + RETVAL_OBJVAL(ov, addref); \ return -#define ZVAL_OBJVAL(zv, ov) \ +#define ZVAL_OBJVAL(zv, ov, addref) \ (zv)->type = IS_OBJECT; \ - (zv)->value.obj = (ov); + (zv)->value.obj = (ov);\ + if (addref && Z_OBJ_HT_P(zv)->add_ref) { \ + Z_OBJ_HT_P(zv)->add_ref((zv) TSRMLS_CC); \ + } /* return property */ #define RETVAL_PROP(n) RETVAL_PROP_EX(getThis(), n) #define RETURN_PROP(n) RETURN_PROP_EX(getThis(), n) -- 2.30.2