add addref param to RETURN_OBJVAL() etc
authorMichael Wallner <mike@php.net>
Fri, 20 Jan 2006 16:48:12 +0000 (16:48 +0000)
committerMichael Wallner <mike@php.net>
Fri, 20 Jan 2006 16:48:12 +0000 (16:48 +0000)
http_message_object.c
http_request_object.c
http_requestpool_object.c
php_http_std_defs.h

index 00fb3cededac04f81a91de025fd5d834018fc66e..475daf13bb1dc300910ba64d3a2ecbd518e72061 100644 (file)
@@ -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);
index 80d802f81ebcdc7cc4e1e1cb63fdce821461e2e2..e6ed74ae0aaafd0dd2e876e746296e8322bdc08e 100644 (file)
@@ -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);
                }
        }
 
index 65eff18c58f08d3e4240e7ee3829acb2ab5942f5..30bfbdea405a0e8dafd3417f8ecc6893099ddf49 100644 (file)
@@ -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();
index aa4f81ef946082c752e41bb6d37e11951958e719..78a9ae2e2ef2dc900be36d9ca7a9dead5b8a74af 100644 (file)
@@ -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)