kernels/linux-2.4.0/mm/mmap_avl.c
/* Insert a node into a tree. */
Insert a node into a tree.
Insert a node into a tree .
static inline void avl_insert (struct vm_area_struct * new_node, struct vm_area_struct ** ptree)
{
	vm_avl_key_t key = new_node->vm_avl_key;
	struct vm_area_struct ** nodeplace = ptree;
	struct vm_area_struct ** stack[avl_maxheight];
	int stack_count = 0;
	struct vm_area_struct *** stack_ptr = &stack[0]; 
	for (;;) {
		struct vm_area_struct * node = *nodeplace;
		if (node == vm_avl_empty)
			break;
		*stack_ptr++ = nodeplace; stack_count++;
		if (key < node->vm_avl_key)
			nodeplace = &node->vm_avl_left;
		else
			nodeplace = &node->vm_avl_right;
	}
	new_node->vm_avl_left = vm_avl_empty;
	new_node->vm_avl_right = vm_avl_empty;
	new_node->vm_avl_height = 1;
	*nodeplace = new_node;
	avl_rebalance(stack_ptr,stack_count);
}
static inline void avl_insert ( struct vm_area_struct * new_node , struct vm_area_struct * * ptree ) { vm_avl_key_t key = new_node -> vm_avl_key ; struct vm_area_struct * * nodeplace = ptree ; struct vm_area_struct * * stack [ avl_maxheight ] ; int stack_count = 0 ; struct vm_area_struct * * * stack_ptr = & stack [ 0 ] ; for ( ; ; ) { struct vm_area_struct * node = * nodeplace ; if ( node == vm_avl_empty ) break ; * stack_ptr ++ = nodeplace ; stack_count ++ ; if ( key < node -> vm_avl_key ) nodeplace = & node -> vm_avl_left ; else nodeplace = & node -> vm_avl_right ; } new_node -> vm_avl_left = vm_avl_empty ; new_node -> vm_avl_right = vm_avl_empty ; new_node -> vm_avl_height = 1 ; * nodeplace = new_node ; avl_rebalance ( stack_ptr , stack_count ) ; }
Insert a node into a tree.
Insert a node into a tree .
/* = &stack[stackcount] */