}
-addrmap_fixed::addrmap_fixed (struct obstack *obstack, addrmap_mutable *mut)
+addrmap_fixed::addrmap_fixed (struct obstack *obstack,
+ const addrmap_mutable *mut)
{
size_t transition_count = 0;
/* Count the number of transitions in the tree. */
- mut->foreach ([&] (CORE_ADDR start, void *obj)
+ mut->foreach ([&] (CORE_ADDR start, const void *obj)
{
++transition_count;
return 0;
/* Copy all entries from the splay tree to the array, in order
of increasing address. */
- mut->foreach ([&] (CORE_ADDR start, void *obj)
+ mut->foreach ([&] (CORE_ADDR start, const void *obj)
{
transitions[num_transitions].addr = start;
- transitions[num_transitions].value = obj;
+ transitions[num_transitions].value = const_cast<void *> (obj);
++num_transitions;
return 0;
});
addrmap_mutable::~addrmap_mutable ()
{
- splay_tree_delete (tree);
+ if (tree != nullptr)
+ splay_tree_delete (tree);
}
{
public:
- addrmap_fixed (struct obstack *obstack, addrmap_mutable *mut);
+ addrmap_fixed (struct obstack *obstack, const addrmap_mutable *mut);
DISABLE_COPY_AND_ASSIGN (addrmap_fixed);
+ /* It's fine to use the default move operators, because this addrmap
+ does not own the storage for the elements. */
+ addrmap_fixed (addrmap_fixed &&other) = default;
+ addrmap_fixed &operator= (addrmap_fixed &&) = default;
+
void relocate (CORE_ADDR offset) override;
private:
~addrmap_mutable ();
DISABLE_COPY_AND_ASSIGN (addrmap_mutable);
+ addrmap_mutable (addrmap_mutable &&other)
+ : tree (other.tree)
+ {
+ other.tree = nullptr;
+ }
+
+ addrmap_mutable &operator= (addrmap_mutable &&other)
+ {
+ std::swap (tree, other.tree);
+ return *this;
+ }
+
/* In the mutable address map MAP, associate the addresses from START
to END_INCLUSIVE that are currently associated with NULL with OBJ
instead. Addresses mapped to an object other than NULL are left