]> granicus.if.org Git - php/commitdiff
- Merge Sterling's patches from ZE1
authorAndi Gutmans <andi@php.net>
Sat, 18 Aug 2001 18:16:49 +0000 (18:16 +0000)
committerAndi Gutmans <andi@php.net>
Sat, 18 Aug 2001 18:16:49 +0000 (18:16 +0000)
Zend/zend_execute.c
Zend/zend_llist.c
Zend/zend_llist.h

index 159bca5b4f185507f2a440cb084c2afba677734e..04ca8dcb8607aec83904b5f694aacdc7605f4478 100644 (file)
@@ -857,8 +857,8 @@ static void zend_fetch_property_address(znode *result, znode *op1, znode *op2, t
        }
 
        if (container->type == IS_OBJECT &&
-               (type == BP_VAR_W && Z_OBJCE_P(container)->handle_property_set ||
-                type != BP_VAR_W && Z_OBJCE_P(container)->handle_property_get)) {
+               ((type == BP_VAR_W && Z_OBJCE_P(container)->handle_property_set) ||
+                (type != BP_VAR_W && Z_OBJCE_P(container)->handle_property_get))) {
                zend_overloaded_element overloaded_element;
 
                Ts[result->u.var].EA.data.overloaded_element.object = container;
index e3e4945fb54a97704ef3f3f35c48c8610056bb37..bca13a6f1f1b8ab6f0383fec09c9ca3ca045d79a 100644 (file)
@@ -64,32 +64,34 @@ ZEND_API void zend_llist_prepend_element(zend_llist *l, void *element)
 
 
 #define DEL_LLIST_ELEMENT(current, l) \
-                       if (current->prev) {\
-                               current->prev->next = current->next;\
+                       if ((current)->prev) {\
+                               (current)->prev->next = (current)->next;\
                        } else {\
-                               l->head = current->next;\
+                               (l)->head = (current)->next;\
                        }\
-                       if (current->next) {\
-                               current->next->prev = current->prev;\
+                       if ((current)->next) {\
+                               (current)->next->prev = (current)->prev;\
                        } else {\
-                               l->tail = current->prev;\
+                               (l)->tail = (current)->prev;\
                        }\
-                       if (l->dtor) {\
-                               l->dtor(current->data);\
-                               pefree(current, l->persistent);\
+                       if ((l)->dtor) {\
+                               (l)->dtor((current)->data);\
+                               pefree((current), (l)->persistent);\
                        }
 
 
 ZEND_API void zend_llist_del_element(zend_llist *l, void *element, int (*compare)(void *element1, void *element2))
 {
        zend_llist_element *current=l->head;
+       zend_llist_element *next;
 
        while (current) {
+               next = current->next;
                if (compare(current->data, element)) {
                        DEL_LLIST_ELEMENT(current, l);
                        break;
                }
-               current = current->next;
+               current = next;
        }
 }
 
@@ -116,17 +118,28 @@ ZEND_API void zend_llist_clean(zend_llist *l)
 }
 
 
-ZEND_API void zend_llist_remove_tail(zend_llist *l)
+ZEND_API void *zend_llist_remove_tail(zend_llist *l)
 {
        zend_llist_element *old_tail;
+       void *data;
 
        if ((old_tail = l->tail)) {
                if (l->tail->prev) {
                        l->tail->prev->next = NULL;
                }
+        
+               /* Save the data, this doesn't get free'd, 
+                * the pointer is just removed from the list
+                */
+               data = old_tail->data;
+
                l->tail = l->tail->prev;
                pefree(old_tail, l->persistent);
+
+               return data;
        }
+
+       return NULL;
 }
 
 
index 63bf6474839726fdac128cf6cca60bcbe24b869a..638e464ef0741d1db7933b773c213a67685861c3 100644 (file)
@@ -53,7 +53,7 @@ ZEND_API void zend_llist_prepend_element(zend_llist *l, void *element);
 ZEND_API void zend_llist_del_element(zend_llist *l, void *element, int (*compare)(void *element1, void *element2));
 ZEND_API void zend_llist_destroy(zend_llist *l);
 ZEND_API void zend_llist_clean(zend_llist *l);
-ZEND_API void zend_llist_remove_tail(zend_llist *l);
+ZEND_API void *zend_llist_remove_tail(zend_llist *l);
 ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src);
 ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func TSRMLS_DC);
 ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data));