Wed Apr 23 13:35:45 PDT 2008
- Previous message: [Slony1-commit] slony1-engine/src/backend slony1_funcs.c slony1_funcs.sql
- Next message: [Slony1-commit] slony1-engine/src/slon/port win32service.c win32service.h
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /home/cvsd/slony1/slony1-engine/src/misc
In directory main.slony.info:/tmp/cvs-serv2424/misc
Modified Files:
avl_tree.c avl_tree.h
Log Message:
Ran pgindent against C code
Index: avl_tree.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/misc/avl_tree.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** avl_tree.c 7 Jun 2007 13:01:10 -0000 1.1
--- avl_tree.c 23 Apr 2008 20:35:43 -0000 1.2
***************
*** 4,11 ****
* AVL style self balancing tree support.
*
! * Copyright (c) 2007, PostgreSQL Global Development Group
! * Author: Jan Wieck, Afilias USA INC.
*
! * $Id$
* ----------------------------------------------------------------------
*/
--- 4,11 ----
* AVL style self balancing tree support.
*
! * Copyright (c) 2007, PostgreSQL Global Development Group
! * Author: Jan Wieck, Afilias USA INC.
*
! * $Id$
* ----------------------------------------------------------------------
*/
***************
*** 17,26 ****
* ----
*/
! static AVLnode *avl_makenode(void);
! static void avl_reset_node(AVLnode *node, AVLfreefunc *freefunc);
! static int avl_insertinto(AVLtree *tree, AVLnode **node,
! void *cdata, AVLnode **result);
! static void avl_rotate_left(AVLnode **node);
! static void avl_rotate_right(AVLnode **node);
--- 17,26 ----
* ----
*/
! static AVLnode *avl_makenode(void);
! static void avl_reset_node(AVLnode *node, AVLfreefunc *freefunc);
! static int avl_insertinto(AVLtree *tree, AVLnode **node,
! void *cdata, AVLnode **result);
! static void avl_rotate_left(AVLnode **node);
! static void avl_rotate_right(AVLnode **node);
***************
*** 64,68 ****
/* ----
! * avl_reset_node() -
*
* avl_reset()'s workhorse.
--- 64,68 ----
/* ----
! * avl_reset_node() -
*
* avl_reset()'s workhorse.
***************
*** 74,78 ****
if (node == NULL)
return;
!
avl_reset_node(node->lnode, freefunc);
avl_reset_node(node->rnode, freefunc);
--- 74,78 ----
if (node == NULL)
return;
!
avl_reset_node(node->lnode, freefunc);
avl_reset_node(node->rnode, freefunc);
***************
*** 96,100 ****
avl_insert(AVLtree *tree, void *cdata)
{
! AVLnode *result;
int depth;
--- 96,100 ----
avl_insert(AVLtree *tree, void *cdata)
{
! AVLnode *result;
int depth;
***************
*** 123,127 ****
avl_lookup(AVLtree *tree, void *cdata)
{
! AVLnode *node;
int cmp;
--- 123,127 ----
avl_lookup(AVLtree *tree, void *cdata)
{
! AVLnode *node;
int cmp;
***************
*** 133,138 ****
{
/*
! * Found the node. If it is marked deleted, return NULL
! * anyway. Otherwise return this node.
*/
if (node->deleted)
--- 133,138 ----
{
/*
! * Found the node. If it is marked deleted, return NULL anyway.
! * Otherwise return this node.
*/
if (node->deleted)
***************
*** 170,174 ****
avl_delete(AVLtree *tree, void *cdata)
{
! AVLnode *node;
if ((node = avl_lookup(tree, cdata)) == NULL)
--- 170,174 ----
avl_delete(AVLtree *tree, void *cdata)
{
! AVLnode *node;
if ((node = avl_lookup(tree, cdata)) == NULL)
***************
*** 186,199 ****
* ----
*/
! static int
avl_insertinto(AVLtree *tree, AVLnode **node,
! void *cdata, AVLnode **result)
{
! int cmp;
/*
* Compare the node at hand with the new elements key.
*/
! cmp = (tree->compfunc)(cdata, (*node)->cdata);
if (cmp > 0)
--- 186,199 ----
* ----
*/
! static int
avl_insertinto(AVLtree *tree, AVLnode **node,
! void *cdata, AVLnode **result)
{
! int cmp;
/*
* Compare the node at hand with the new elements key.
*/
! cmp = (tree->compfunc) (cdata, (*node)->cdata);
if (cmp > 0)
***************
*** 204,212 ****
if ((*node)->rnode == NULL)
{
! /*
! * Right side of current node is empty. Create a new node
! * there and return new maximum depth. Note that this can
! * only be 1 because otherwise this node would have been
! * unbalanced before.
*/
(*node)->rnode = *result = avl_makenode();
--- 204,211 ----
if ((*node)->rnode == NULL)
{
! /*
! * Right side of current node is empty. Create a new node there
! * and return new maximum depth. Note that this can only be 1
! * because otherwise this node would have been unbalanced before.
*/
(*node)->rnode = *result = avl_makenode();
***************
*** 216,228 ****
/*
! * Right hand node exists. Recurse into that and remember the
! * new right hand side depth.
*/
! (*node)->rdepth = avl_insertinto(tree, &((*node)->rnode),
! cdata, result) + 1;
/*
! * A right hand side insert can unbalance this node only to the
! * right.
*/
if (AVL_BALANCE(*node) > 1)
--- 215,226 ----
/*
! * Right hand node exists. Recurse into that and remember the new
! * right hand side depth.
*/
! (*node)->rdepth = avl_insertinto(tree, &((*node)->rnode),
! cdata, result) + 1;
/*
! * A right hand side insert can unbalance this node only to the right.
*/
if (AVL_BALANCE(*node) > 1)
***************
*** 231,236 ****
{
/*
! * RR situation, rebalance the tree by left rotating
! * this node.
*/
avl_rotate_left(node);
--- 229,234 ----
{
/*
! * RR situation, rebalance the tree by left rotating this
! * node.
*/
avl_rotate_left(node);
***************
*** 239,245 ****
{
/*
! * RL situation, rebalance the tree by first right
! * rotating the right hand side, then left rotating
! * this node.
*/
avl_rotate_right(&((*node)->rnode));
--- 237,242 ----
{
/*
! * RL situation, rebalance the tree by first right rotating
! * the right hand side, then left rotating this node.
*/
avl_rotate_right(&((*node)->rnode));
***************
*** 257,265 ****
if ((*node)->lnode == NULL)
{
! /*
! * Left side of current node is empty. Create a new node
! * there and return new maximum depth. Note that this can
! * only be 1 because otherwise this node would have been
! * unbalanced before.
*/
(*node)->lnode = *result = avl_makenode();
--- 254,261 ----
if ((*node)->lnode == NULL)
{
! /*
! * Left side of current node is empty. Create a new node there and
! * return new maximum depth. Note that this can only be 1 because
! * otherwise this node would have been unbalanced before.
*/
(*node)->lnode = *result = avl_makenode();
***************
*** 269,281 ****
/*
! * Left hand node exists. Recurse into that and remember the
! * new left hand side depth.
*/
! (*node)->ldepth = avl_insertinto(tree, &((*node)->lnode),
! cdata, result) + 1;
/*
! * A left hand side insert can unbalance this node only to the
! * left.
*/
if (AVL_BALANCE(*node) < -1)
--- 265,276 ----
/*
! * Left hand node exists. Recurse into that and remember the new left
! * hand side depth.
*/
! (*node)->ldepth = avl_insertinto(tree, &((*node)->lnode),
! cdata, result) + 1;
/*
! * A left hand side insert can unbalance this node only to the left.
*/
if (AVL_BALANCE(*node) < -1)
***************
*** 284,289 ****
{
/*
! * LL situation, rebalance the tree by right rotating
! * this node.
*/
avl_rotate_right(node);
--- 279,284 ----
{
/*
! * LL situation, rebalance the tree by right rotating this
! * node.
*/
avl_rotate_right(node);
***************
*** 292,297 ****
{
/*
! * LR situation, rebalance the tree by first left rotating
! * the left node, then right rotating this node.
*/
avl_rotate_left(&((*node)->lnode));
--- 287,292 ----
{
/*
! * LR situation, rebalance the tree by first left rotating the
! * left node, then right rotating this node.
*/
avl_rotate_left(&((*node)->lnode));
***************
*** 302,315 ****
return AVL_MAXDEPTH(*node);
}
! else {
/*
! * The new element is equal to this node. If it is marked
! * for deletion, free the user element data now. The caller
! * is supposed to replace it with a new element having the
! * the key.
*/
if ((*node)->deleted && tree->freefunc != NULL)
{
! (tree->freefunc)((*node)->cdata);
(*node)->cdata = NULL;
(*node)->deleted = 0;
--- 297,310 ----
return AVL_MAXDEPTH(*node);
}
! else
! {
/*
! * The new element is equal to this node. If it is marked for
! * deletion, free the user element data now. The caller is supposed to
! * replace it with a new element having the the key.
*/
if ((*node)->deleted && tree->freefunc != NULL)
{
! (tree->freefunc) ((*node)->cdata);
(*node)->cdata = NULL;
(*node)->deleted = 0;
***************
*** 327,336 ****
* ----
*/
! static AVLnode *
avl_makenode(void)
{
! AVLnode *new;
! new = (AVLnode *)malloc(sizeof(AVLnode));
memset(new, 0, sizeof(AVLnode));
--- 322,331 ----
* ----
*/
! static AVLnode *
avl_makenode(void)
{
! AVLnode *new;
! new = (AVLnode *) malloc(sizeof(AVLnode));
memset(new, 0, sizeof(AVLnode));
***************
*** 348,352 ****
avl_rotate_left(AVLnode **node)
{
! AVLnode *rtmp;
/*
--- 343,347 ----
avl_rotate_left(AVLnode **node)
{
! AVLnode *rtmp;
/*
***************
*** 386,390 ****
avl_rotate_right(AVLnode **node)
{
! AVLnode *ltmp;
/*
--- 381,385 ----
avl_rotate_right(AVLnode **node)
{
! AVLnode *ltmp;
/*
***************
*** 413,416 ****
*node = ltmp;
}
-
-
--- 408,409 ----
Index: avl_tree.h
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/misc/avl_tree.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** avl_tree.h 7 Jun 2007 13:01:10 -0000 1.1
--- avl_tree.h 23 Apr 2008 20:35:43 -0000 1.2
***************
*** 4,11 ****
* Declarations for AVL style balanced tree support.
*
! * Copyright (c) 2003-2007, PostgreSQL Global Development Group
! * Author: Jan Wieck, Afilias USA INC.
*
! * $Id$
* ----------------------------------------------------------------------
*/
--- 4,11 ----
* Declarations for AVL style balanced tree support.
*
! * Copyright (c) 2003-2007, PostgreSQL Global Development Group
! * Author: Jan Wieck, Afilias USA INC.
*
! * $Id$
* ----------------------------------------------------------------------
*/
***************
*** 18,22 ****
* ----
*/
! typedef int (AVLcompfunc) (void *, void *);
typedef void (AVLfreefunc) (void *);
--- 18,22 ----
* ----
*/
! typedef int (AVLcompfunc) (void *, void *);
typedef void (AVLfreefunc) (void *);
***************
*** 26,40 ****
* ----
*/
! typedef struct AVLnode_s {
! struct AVLnode_s *lnode, *rnode;
! int ldepth, rdepth;
! void *cdata;
! int deleted;
} AVLnode;
! typedef struct AVLtree_s {
! AVLnode *root;
! AVLcompfunc *compfunc;
! AVLfreefunc *freefunc;
} AVLtree;
--- 26,44 ----
* ----
*/
! typedef struct AVLnode_s
! {
! struct AVLnode_s *lnode,
! *rnode;
! int ldepth,
! rdepth;
! void *cdata;
! int deleted;
} AVLnode;
! typedef struct AVLtree_s
! {
! AVLnode *root;
! AVLcompfunc *compfunc;
! AVLfreefunc *freefunc;
} AVLtree;
***************
*** 45,49 ****
#define AVL_DATA(n) (n)->cdata
#define AVL_SETDATA(n,p) ((n)->cdata = (p))
! #define AVL_MAXDEPTH(n) (((n)->ldepth > (n)->rdepth) ? (n)->ldepth : (n)->rdepth)
#define AVL_BALANCE(n) ((n)->rdepth - (n)->ldepth)
--- 49,53 ----
#define AVL_DATA(n) (n)->cdata
#define AVL_SETDATA(n,p) ((n)->cdata = (p))
! #define AVL_MAXDEPTH(n) (((n)->ldepth > (n)->rdepth) ? (n)->ldepth : (n)->rdepth)
#define AVL_BALANCE(n) ((n)->rdepth - (n)->ldepth)
***************
*** 55,64 ****
* ----
*/
! void avl_init(AVLtree *tree, AVLcompfunc *compfunc,
! AVLfreefunc *freefunc);
void avl_reset(AVLtree *tree);
! AVLnode *avl_insert(AVLtree *tree, void *cdata);
! AVLnode *avl_lookup(AVLtree *tree, void *cdata);
int avl_delete(AVLtree *tree, void *cdata);
! #endif /* _AVL_TREE_H_INCLUDED_ */
--- 59,68 ----
* ----
*/
! void avl_init(AVLtree *tree, AVLcompfunc *compfunc,
! AVLfreefunc *freefunc);
void avl_reset(AVLtree *tree);
! AVLnode *avl_insert(AVLtree *tree, void *cdata);
! AVLnode *avl_lookup(AVLtree *tree, void *cdata);
int avl_delete(AVLtree *tree, void *cdata);
! #endif /* _AVL_TREE_H_INCLUDED_ */
- Previous message: [Slony1-commit] slony1-engine/src/backend slony1_funcs.c slony1_funcs.sql
- Next message: [Slony1-commit] slony1-engine/src/slon/port win32service.c win32service.h
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list