diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2018-11-06 13:25:24 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2018-11-06 13:25:24 -0500 |
commit | 1f28ec6be27085819a6adfa96ba305bb4ee47f4c (patch) | |
tree | 67de5c6ad287fde5bed6735d773364d10a275e7b /src/include/lib/rbtree.h | |
parent | fef63a80bba7048b5a7e642cc5e6a5b9d25589a1 (diff) | |
download | postgresql-1f28ec6be27085819a6adfa96ba305bb4ee47f4c.tar.gz postgresql-1f28ec6be27085819a6adfa96ba305bb4ee47f4c.zip |
Rename rbtree.c functions to use "rbt" prefix not "rb" prefix.
The "rb" prefix is used by Ruby, so that our existing code results
in name collisions that break plruby. We discussed ways to prevent
that by adjusting dynamic linker options, but it seems that at best
we'd move the pain to other cases. Renaming to avoid the collision
is the only portable fix anyway. Fortunately, our rbtree code is
not (yet?) widely used --- in core, there's only a single usage
in GIN --- so it seems likely that we can get away with a rename.
I chose to do this basically as s/rb/rbt/g, except for places where
there already was a "t" after "rb". The patch could have been made
smaller by only touching linker-visible symbols, but it would have
resulted in oddly inconsistent-looking code. Better to make it look
like "rbt" was the plan all along.
Back-patch to v10. The rbtree.c code exists back to 9.5, but
rb_iterate() which is the actual immediate source of pain was added
in v10, so it seems like changing the names before that would have
more risk than benefit.
Per report from Pavel Raiskup.
Discussion: https://postgr.es/m/4738198.8KVIIDhgEB@nb.usersys.redhat.com
Diffstat (limited to 'src/include/lib/rbtree.h')
-rw-r--r-- | src/include/lib/rbtree.h | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/include/lib/rbtree.h b/src/include/lib/rbtree.h index c46db47a750..51e4ed321cb 100644 --- a/src/include/lib/rbtree.h +++ b/src/include/lib/rbtree.h @@ -14,29 +14,29 @@ #define RBTREE_H /* - * RBNode is intended to be used as the first field of a larger struct, + * RBTNode is intended to be used as the first field of a larger struct, * whose additional fields carry whatever payload data the caller needs * for a tree entry. (The total size of that larger struct is passed to - * rb_create.) RBNode is declared here to support this usage, but + * rbt_create.) RBTNode is declared here to support this usage, but * callers must treat it as an opaque struct. */ -typedef struct RBNode +typedef struct RBTNode { char color; /* node's current color, red or black */ - struct RBNode *left; /* left child, or RBNIL if none */ - struct RBNode *right; /* right child, or RBNIL if none */ - struct RBNode *parent; /* parent, or NULL (not RBNIL!) if none */ -} RBNode; + struct RBTNode *left; /* left child, or RBTNIL if none */ + struct RBTNode *right; /* right child, or RBTNIL if none */ + struct RBTNode *parent; /* parent, or NULL (not RBTNIL!) if none */ +} RBTNode; /* Opaque struct representing a whole tree */ typedef struct RBTree RBTree; /* Available tree iteration orderings */ -typedef enum RBOrderControl +typedef enum RBTOrderControl { LeftRightWalk, /* inorder: left child, node, right child */ RightLeftWalk /* reverse inorder: right, node, left */ -} RBOrderControl; +} RBTOrderControl; /* * RBTreeIterator holds state while traversing a tree. This is declared @@ -47,33 +47,33 @@ typedef struct RBTreeIterator RBTreeIterator; struct RBTreeIterator { - RBTree *rb; - RBNode *(*iterate) (RBTreeIterator *iter); - RBNode *last_visited; + RBTree *rbt; + RBTNode *(*iterate) (RBTreeIterator *iter); + RBTNode *last_visited; bool is_over; }; /* Support functions to be provided by caller */ -typedef int (*rb_comparator) (const RBNode *a, const RBNode *b, void *arg); -typedef void (*rb_combiner) (RBNode *existing, const RBNode *newdata, void *arg); -typedef RBNode *(*rb_allocfunc) (void *arg); -typedef void (*rb_freefunc) (RBNode *x, void *arg); +typedef int (*rbt_comparator) (const RBTNode *a, const RBTNode *b, void *arg); +typedef void (*rbt_combiner) (RBTNode *existing, const RBTNode *newdata, void *arg); +typedef RBTNode *(*rbt_allocfunc) (void *arg); +typedef void (*rbt_freefunc) (RBTNode *x, void *arg); -extern RBTree *rb_create(Size node_size, - rb_comparator comparator, - rb_combiner combiner, - rb_allocfunc allocfunc, - rb_freefunc freefunc, - void *arg); +extern RBTree *rbt_create(Size node_size, + rbt_comparator comparator, + rbt_combiner combiner, + rbt_allocfunc allocfunc, + rbt_freefunc freefunc, + void *arg); -extern RBNode *rb_find(RBTree *rb, const RBNode *data); -extern RBNode *rb_leftmost(RBTree *rb); +extern RBTNode *rbt_find(RBTree *rbt, const RBTNode *data); +extern RBTNode *rbt_leftmost(RBTree *rbt); -extern RBNode *rb_insert(RBTree *rb, const RBNode *data, bool *isNew); -extern void rb_delete(RBTree *rb, RBNode *node); +extern RBTNode *rbt_insert(RBTree *rbt, const RBTNode *data, bool *isNew); +extern void rbt_delete(RBTree *rbt, RBTNode *node); -extern void rb_begin_iterate(RBTree *rb, RBOrderControl ctrl, - RBTreeIterator *iter); -extern RBNode *rb_iterate(RBTreeIterator *iter); +extern void rbt_begin_iterate(RBTree *rbt, RBTOrderControl ctrl, + RBTreeIterator *iter); +extern RBTNode *rbt_iterate(RBTreeIterator *iter); #endif /* RBTREE_H */ |