AVL node/tree: make non-copyable

AVL trees can't be copied with the default copy constructor as the
parent pointer of the first item of both of the resulting trees would
point to the original tree. Copying an AVL node, however, generally
violates the integrity of the corresponding tree. The copy constructor
of Avl_tree is used in some places but in those places it can be
replaced easily. So, this commit deletes the copy constructor of
Avl_node_base which makes Avl_node and Avl_tree non-copyable.

Issue #2654
This commit is contained in:
Martin Stein
2018-01-24 14:02:35 +01:00
committed by Norman Feske
parent 4e9ff5ad7b
commit abf9557bb5
13 changed files with 84 additions and 55 deletions

View File

@ -15,6 +15,7 @@
#define _INCLUDE__UTIL__AVL_TREE_H_
#include <util/misc_math.h>
#include <util/noncopyable.h>
namespace Genode {
@ -24,7 +25,7 @@ namespace Genode {
}
class Genode::Avl_node_base
class Genode::Avl_node_base : Noncopyable
{
protected:
@ -58,9 +59,11 @@ class Genode::Avl_node_base
virtual void recompute(Avl_node_base *) { }
};
Avl_node_base *_child[2]; /* left and right subtrees */
Avl_node_base *_parent; /* parent of subtree */
unsigned char _depth; /* depth of subtree */
struct {
Avl_node_base *_child[2]; /* left and right subtrees */
Avl_node_base *_parent; /* parent of subtree */
unsigned char _depth; /* depth of subtree */
};
public: