kernels/linux-2.4.0/mm/mmap_avl.c
/* Look up the nodes at the left and at the right of a given node. */
Look up the nodes at the left and at the right of a given node.
Look up the nodes at the left and at the right of a given node .
static void avl_neighbours (struct vm_area_struct * node, struct vm_area_struct * tree, struct vm_area_struct ** to_the_left, struct vm_area_struct ** to_the_right)
{
	vm_avl_key_t key = node->vm_avl_key;
	*to_the_left = *to_the_right = NULL;
	for (;;) {
		if (tree == vm_avl_empty) {
			printk("avl_neighbours: node not found in the tree\n");
			return;
		}
		if (key == tree->vm_avl_key)
			break;
		if (key < tree->vm_avl_key) {
			*to_the_right = tree;
			tree = tree->vm_avl_left;
		} else {
			*to_the_left = tree;
			tree = tree->vm_avl_right;
		}
	}
	if (tree != node) {
		printk("avl_neighbours: node not exactly found in the tree\n");
		return;
	}
	if (tree->vm_avl_left != vm_avl_empty) {
		struct vm_area_struct * node;
		for (node = tree->vm_avl_left; node->vm_avl_right != vm_avl_empty; node = node->vm_avl_right)
			continue;
		*to_the_left = node;
	}
	if (tree->vm_avl_right != vm_avl_empty) {
		struct vm_area_struct * node;
		for (node = tree->vm_avl_right; node->vm_avl_left != vm_avl_empty; node = node->vm_avl_left)
			continue;
		*to_the_right = node;
	}
	if ((*to_the_left && ((*to_the_left)->vm_next != node)) || (node->vm_next != *to_the_right))
		printk("avl_neighbours: tree inconsistent with list\n");
}
static void avl_neighbours ( struct vm_area_struct * node , struct vm_area_struct * tree , struct vm_area_struct * * to_the_left , struct vm_area_struct * * to_the_right ) { vm_avl_key_t key = node -> vm_avl_key ; * to_the_left = * to_the_right = NULL ; for ( ; ; ) { if ( tree == vm_avl_empty ) { printk ( " \n " ) ; return ; } if ( key == tree -> vm_avl_key ) break ; if ( key < tree -> vm_avl_key ) { * to_the_right = tree ; tree = tree -> vm_avl_left ; } else { * to_the_left = tree ; tree = tree -> vm_avl_right ; } } if ( tree != node ) { printk ( " \n " ) ; return ; } if ( tree -> vm_avl_left != vm_avl_empty ) { struct vm_area_struct * node ; for ( node = tree -> vm_avl_left ; node -> vm_avl_right != vm_avl_empty ; node = node -> vm_avl_right ) continue ; * to_the_left = node ; } if ( tree -> vm_avl_right != vm_avl_empty ) { struct vm_area_struct * node ; for ( node = tree -> vm_avl_right ; node -> vm_avl_left != vm_avl_empty ; node = node -> vm_avl_left ) continue ; * to_the_right = node ; } if ( ( * to_the_left && ( ( * to_the_left ) -> vm_next != node ) ) || ( node -> vm_next != * to_the_right ) ) printk ( " \n " ) ; }
Look up the nodes at the left and at the right of a given node.
Look up the nodes at the left and at the right of a given node .