]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - repair/avl64.c
Update copyright/license notices to match SGI legal prefered boilerplate.
[thirdparty/xfsprogs-dev.git] / repair / avl64.c
index 4308dcaf2c496a19ab124707884cb5c846522663..fc4cab4570418e87af002344b1ac68111ea1a639 100644 (file)
@@ -1,36 +1,20 @@
-/**************************************************************************
- *                                                                       *
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
+/*
+ * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
  * published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * 
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- *                                                                       *
- **************************************************************************/
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
 #include <stdio.h>
 #include <libxfs.h>
@@ -193,7 +177,7 @@ retreat(
                                 * np gets pushed down to lesser child's
                                 * avl_forw branch.
                                 *
-                                *  np->    -D              +B
+                                *  np->    -D              +B
                                 *          / \             / \
                                 * child-> B   deleted     A  -D
                                 *        / \                 /
@@ -241,7 +225,7 @@ retreat(
                         * child's avl_forw node gets promoted up, along with
                         * its avl_forw subtree
                         *
-                        *  np->     -G                   C
+                        *  np->     -G                   C
                         *           / \                 / \
                         * child-> +B   H              -B   G
                         *         / \   \             /   / \
@@ -290,7 +274,7 @@ retreat(
                         * np gets pushed down to greater child's
                         * avl_back branch.
                         *
-                        *  np->    +B               -D
+                        *  np->    +B               -D
                         *          / \              / \
                         *   deleted   D <-child   +B   E
                         *            / \            \
@@ -433,19 +417,19 @@ avl64_delete(
                ASSERT(nnext->avl_nextino == np);
                nnext->avl_nextino = np->avl_nextino;
                /*
-                *      Something preceeds np; np cannot be firstino.
+                *      Something preceeds np; np cannot be firstino.
                 */
                ASSERT(tree->avl_firstino != np);
        }
        else {
                /*
-                *      Nothing preceeding np; after deletion, np's nextino
-                *      is firstino of tree.
+                *      Nothing preceeding np; after deletion, np's nextino
+                *      is firstino of tree.
                 */
                ASSERT(tree->avl_firstino == np);
                tree->avl_firstino = np->avl_nextino;
        }
-       
+
 
        /*
         * Degenerate cases...
@@ -499,7 +483,7 @@ attach:
                back->avl_forw = forw = np->avl_forw;
                forw->avl_parent = back;
                back->avl_parent = parent;
-               
+
                if (parent) {
                        if (parent->avl_forw == np)
                                parent->avl_forw = back;
@@ -531,7 +515,7 @@ attach:
         *          / \                       / \
         *         G   J             back->  G   J   (before retreat())
         *        / \                       / \
-        *       F   ?...                  F   ?1
+        *       F   ?...                  F   ?1
         *      /     \
         *     ?       H  <-forw
         *            /
@@ -544,7 +528,7 @@ attach:
         * Will be adjusted by retreat() below.
         */
        forw->avl_balance = np->avl_balance;
-       
+
        /*
         * forw inherits np's avl_forw...
         */
@@ -590,20 +574,20 @@ attach:
 
 
 /*
- *     avl_findanyrange:
- *     
+ *     avl_findanyrange:
+ *
  *     Given range r [start, end), find any range which is contained in r.
  *     if checklen is non-zero, then only ranges of non-zero length are
- *     considered in finding a match.
+ *     considered in finding a match.
  */
 avl64node_t *
 avl64_findanyrange(
        register avl64tree_desc_t *tree,
        register __uint64_t start,
        register __uint64_t end,
-       int     checklen)
+       int     checklen)
 {
-        register avl64node_t *np = tree->avl_root;
+       register avl64node_t *np = tree->avl_root;
 
        /* np = avl64_findadjacent(tree, start, AVL_SUCCEED); */
        while (np) {
@@ -625,7 +609,7 @@ avl64_findanyrange(
                                continue;
                        }
                        /* if we were to add node with start, would
-                        * have a growth of AVL_FORW; 
+                        * have a growth of AVL_FORW;
                         */
                        /* we are looking for a succeeding node;
                         * this is nextino.
@@ -648,7 +632,7 @@ avl64_findanyrange(
                        return(np);
                }
                /*
-                * find non-zero length region 
+                * find non-zero length region
                 */
                while (np && (AVL_END(tree, np) - AVL_START(tree, np) == 0)
                        && (AVL_START(tree, np)  < end))
@@ -810,7 +794,7 @@ avl64_balance(
                                             / \             / \
                                child->    +B   F          -B   E
                                           / \             /   / \
-                                         A  +C           A   D   F
+                                         A  +C           A   D   F
                                               \
                                                D
 
@@ -925,9 +909,9 @@ static
 avl64node_t *
 avl64_insert_find_growth(
                register avl64tree_desc_t *tree,
-               register __uint64_t start,      /* range start at start, */
-               register __uint64_t end,        /* exclusive */
-               register int   *growthp)        /* OUT */ 
+               register __uint64_t start,      /* range start at start, */
+               register __uint64_t end,        /* exclusive */
+               register int   *growthp)        /* OUT */
 {
        avl64node_t *root = tree->avl_root;
        register avl64node_t *np;
@@ -1045,7 +1029,7 @@ avl64_insert(
                        == NULL) {
                if (start != end)  { /* non-zero length range */
                        fprintf(stderr,
-                       "avl_insert: Warning! duplicate range [%llu,%llu]\n",
+               _("avl_insert: Warning! duplicate range [%llu,%llu]\n"),
                                (unsigned long long)start,
                                (unsigned long long)end);
                }
@@ -1082,7 +1066,7 @@ avl64_insert(
 /*
  *
  * avl64_insert_immediate(tree, afterp, newnode):
- *     insert newnode immediately into tree immediately after afterp.
+ *     insert newnode immediately into tree immediately after afterp.
  *     after insertion, newnode is right child of afterp.
  */
 void
@@ -1189,8 +1173,8 @@ avl64_debug_end(avl64node_t *node)
                 (struct avl_debug_node *)node->avl_size);
 }
 
-avl_debug_node         freenodes[100];
-avl_debug_node         *freehead = &freenodes[0];
+avl_debug_node freenodes[100];
+avl_debug_node *freehead = &freenodes[0];
 
 static avl64node_t *
 alloc_avl64_debug_node()
@@ -1218,15 +1202,15 @@ avl64_print(avl64tree_desc_t *tree, avl64node_t *root, int depth)
 
 main()
 {
-       int             i, j;
-       avl64node_t     *np;
+       int             i, j;
+       avl64node_t     *np;
        avl64tree_desc_t        tree;
        char            linebuf[256], cmd[256];
 
        avl64_init_tree(&tree, &avl_debug_ops);
 
        for (i = 100; i > 0; i = i - 10)
-       {       
+       {
                np = alloc__debug_avlnode();
                ASSERT(np);
                np->avl_start = i;
@@ -1281,7 +1265,7 @@ main()
                        avl64_insert(&tree, np);
                        break;
                case 'r': {
-                       avl64node_t     *b, *e, *t;
+                       avl64node_t     *b, *e, *t;
                        int             checklen;
 
                        printf("End of range ? ");
@@ -1313,9 +1297,9 @@ main()
 #endif
 
 /*
- *     Given a tree, find value; will find return range enclosing value,
+ *     Given a tree, find value; will find return range enclosing value,
  *     or range immediately succeeding value,
- *     or range immediately preceeding value.
+ *     or range immediately preceeding value.
  */
 avl64node_t *
 avl64_findadjacent(
@@ -1323,7 +1307,7 @@ avl64_findadjacent(
        register __uint64_t value,
        register int            dir)
 {
-        register avl64node_t *np = tree->avl_root;
+       register avl64node_t *np = tree->avl_root;
 
        while (np) {
                if (value < AVL_START(tree, np)) {
@@ -1360,7 +1344,7 @@ avl64_findadjacent(
                                continue;
                        }
                        /* if we were to add node with value, would
-                        * have a growth of AVL_FORW; 
+                        * have a growth of AVL_FORW;
                         */
                        if (dir == AVL_SUCCEED) {
                                /* we are looking for a succeeding node;
@@ -1371,7 +1355,7 @@ avl64_findadjacent(
                        if (dir == AVL_PRECEED) {
                                /* looking for a preceeding node; this is it. */
                                return(np);
-                       }       
+                       }
                        ASSERT(dir == AVL_SUCCEED || dir == AVL_PRECEED);
                }
                /* AVL_START(tree, np) <= value < AVL_END(tree, np) */
@@ -1382,11 +1366,11 @@ avl64_findadjacent(
 
 
 /*
- *     avl_findranges:
+ *     avl_findranges:
  *
  *     Given range r [start, end), find all ranges in tree which are contained
  *     in r. At return, startp and endp point to first and last of
- *     a chain of elements which describe the contained ranges. Elements
+ *     a chain of elements which describe the contained ranges. Elements
  *     in startp ... endp are in sort order, and can be accessed by
  *     using avl_nextino.
  */
@@ -1396,13 +1380,13 @@ avl64_findranges(
        register avl64tree_desc_t *tree,
        register __uint64_t start,
        register __uint64_t end,
-       avl64node_t             **startp,
+       avl64node_t             **startp,
        avl64node_t             **endp)
 {
-        register avl64node_t *np;
+       register avl64node_t *np;
 
        np = avl64_findadjacent(tree, start, AVL_SUCCEED);
-       if (np == NULL                          /* nothing succeding start */
+       if (np == NULL                          /* nothing succeding start */
                || (np && (end <= AVL_START(tree, np))))
                                                /* something follows start,
                                                but... is entirely after end */