pike.git / src / rbtree.c

version» Context lines:

pike.git/src/rbtree.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: rbtree.c,v 1.22 2002/12/22 17:18:55 mast Exp $ + || $Id: rbtree.c,v 1.23 2002/12/23 13:14:07 grubba Exp $   */      /* An implementation of a threaded red/black balanced binary tree.    *    * Created 2001-04-27 by Martin Stjernholm <mast@lysator.liu.se>    */      #include "global.h"    - RCSID("$Id: rbtree.c,v 1.22 2002/12/22 17:18:55 mast Exp $"); + RCSID("$Id: rbtree.c,v 1.23 2002/12/23 13:14:07 grubba Exp $");      #include "interpret.h"   #include "pike_error.h"   #include "rbtree_low.h"      #include <assert.h>   #include <stdlib.h>      #if defined (PIKE_DEBUG) || defined (TEST_MULTISET)   
pike.git/src/rbtree.c:796:       new->flags |= RB_RED | RB_THREAD_PREV | RB_THREAD_NEXT;    new->prev = parent;    new->next = parent->next;    parent->flags &= ~RB_THREAD_NEXT;    parent->next = new;       *root = rebalance_after_add (new, rbstack);   }    - #define DO_SIMPLE_UNLINK(UNLINK, PARENT, NODE) do { \ + #define DO_SIMPLE_UNLINK(UNLINK, PARENT, NODE) \ +  do { \    PARENT = RBSTACK_PEEK (rbstack); \    \    if (UNLINK->flags & RB_THREAD_PREV) { \    if (UNLINK->flags & RB_THREAD_NEXT) { \    if (PARENT) \    SET_PTR_TO_CHILD ( \    PARENT, UNLINK, \    (PARENT->flags |= RB_THREAD_PREV, NODE = UNLINK->prev), \    (PARENT->flags |= RB_THREAD_NEXT, NODE = UNLINK->next)); \    else \    NODE = NULL; \ -  goto simple_unlink_done; \ +  break; /* We're done. */ \    } \    \    else { /* prev is null. */ \    NODE = UNLINK->next; \    DO_IF_DEBUG ( \    /* Since UNLINK->prev is null, UNLINK->next must be red */ \    /* and can't have children, or else the tree is */ \    /* unbalanced. */ \    if (!(NODE->flags & RB_THREAD_PREV)) \    rb_fatal (PARENT, "Expected thread prev pointer in %p; " \
pike.git/src/rbtree.c:836:    NODE = UNLINK->prev; \    DO_IF_DEBUG ( \    if (!(NODE->flags & RB_THREAD_NEXT)) \    rb_fatal (PARENT, "Expected thread next pointer in %p; " \    "tree is unbalanced.\n", NODE); \    ); \    NODE->next = UNLINK->next; \    } \    \    if (PARENT) SET_PTR_TO_CHILD (PARENT, UNLINK, NODE, NODE); \ -  simple_unlink_done:; \ +     } while (0)      #define ADJUST_STACK_TO_NEXT(RBSTACK, NEXT) do { \    struct rb_node_hdr *node = RBSTACK_PEEK (RBSTACK); \    if (NEXT && (!node || \    (!(node->flags & RB_THREAD_PREV) && node->prev == NEXT) || \    (!(node->flags & RB_THREAD_NEXT) && node->next == NEXT))) { \    RBSTACK_PUSH (RBSTACK, NEXT); \    while (!(NEXT->flags & RB_THREAD_PREV)) \    RBSTACK_PUSH (RBSTACK, NEXT = NEXT->prev); \