diff options
author | Tom Tromey <tom@tromey.com> | 2024-01-14 11:51:38 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2024-04-16 11:54:46 -0600 |
commit | 79ddf4a51a789c823d024409aec8712595701a23 (patch) | |
tree | 4ec64ad9589fa4173a79dea01496249f30875915 /gdb/addrmap.c | |
parent | 4e417d7bb1c7d8b8a73b73b0b7c051f0a6e1b6b6 (diff) | |
download | binutils-79ddf4a51a789c823d024409aec8712595701a23.zip binutils-79ddf4a51a789c823d024409aec8712595701a23.tar.gz binutils-79ddf4a51a789c823d024409aec8712595701a23.tar.bz2 |
Add move operators for addrmap
A subsequent patch needs to move an addrmap. This patch adds the
necessary support. It also changes addrmap_fixed to take a 'const'
addrmap_mutable. This is fine according to the contract of
addrmap_mutable; but it did require a compensating const_cast in the
implementation.
Diffstat (limited to 'gdb/addrmap.c')
-rw-r--r-- | gdb/addrmap.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/gdb/addrmap.c b/gdb/addrmap.c index 0c60c0c..c6e0373 100644 --- a/gdb/addrmap.c +++ b/gdb/addrmap.c @@ -250,12 +250,13 @@ addrmap_mutable::do_find (CORE_ADDR addr) const } -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; @@ -273,10 +274,10 @@ addrmap_fixed::addrmap_fixed (struct obstack *obstack, addrmap_mutable *mut) /* 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; }); @@ -344,7 +345,8 @@ addrmap_mutable::addrmap_mutable () addrmap_mutable::~addrmap_mutable () { - splay_tree_delete (tree); + if (tree != nullptr) + splay_tree_delete (tree); } |