avl.c revision fa9e4066f08beec538e775443c5be79dd423fcab
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <mdb/mdb_modapi.h>
struct aw_info {
void *aw_buff; /* buffer to hold the tree's data structure */
};
/*
* common code used to find the addr of the the leftmost child below
* an AVL node
*/
static uintptr_t
{
for (;;) {
return ((uintptr_t)-1L);
}
break;
}
return (addr);
}
/*
* initialize a forward walk thru an avl tree.
*/
int
{
/*
* allocate the AVL walk data
*/
/*
* get an mdb copy of the avl_tree_t being walked
*/
goto error;
}
mdb_warn("invalid avl_tree_t at %p, avl_size:%d, avl_offset:%d",
goto error;
}
/*
* allocate a buffer to hold the mdb copy of tree's structs
* "node" always points at the avl_node_t field inside the struct
*/
/*
* get the first avl_node_t address, use same algorithm
* as avl_start() -- leftmost child in tree from root
*/
return (WALK_NEXT);
}
goto error;
return (WALK_NEXT);
return (WALK_ERR);
}
/*
* At each step, visit (callback) the current node, then move to the next
* in the AVL tree. Uses the same algorithm as avl_walk().
*/
int
{
int status;
int was_child;
/*
* don't walk past the end of the tree!
*/
return (WALK_DONE);
/*
* must read the current node for the call back to use
*/
return (WALK_ERR);
}
/*
* do the call back
*/
return (status);
/*
* move to the next node....
* note we read in new nodes, so the pointer to the buffer is fixed
*/
/*
* if the node has a right child then go to it and then all the way
* thru as many left children as possible
*/
return (WALK_ERR);
/*
* othewise return to parent nodes, stopping if we ever return from
* a left child
*/
} else {
for (;;) {
break;
if (was_child == 0) /* stop on return from left child */
break;
return (WALK_ERR);
}
}
}
return (WALK_NEXT);
}
/*
* Release the memory allocated for the walk
*/
void
{
return;
}