summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-11-26 09:05:48 -0800
committerGitHub <noreply@github.com>2024-11-26 09:05:48 -0800
commitcc97853b5f03e8c8441159e68ecb2262beee166f (patch)
treeecf63827f726ff0401aa47a250539138b77a6a3c /src
parentf7afec956917c51071867f5b1b487111f1a1ef60 (diff)
downloadbinaryen-cc97853b5f03e8c8441159e68ecb2262beee166f.tar.gz
binaryen-cc97853b5f03e8c8441159e68ecb2262beee166f.tar.bz2
binaryen-cc97853b5f03e8c8441159e68ecb2262beee166f.zip
Fix ArenaVector::swap (#7115)
This was never right for over a decade, and just never used I suppose... it should have been called "take" since it grabbed data from the other item and then set that other item to empty. Fix it so it swaps properly.
Diffstat (limited to 'src')
-rw-r--r--src/mixed_arena.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/mixed_arena.h b/src/mixed_arena.h
index 530fa9daa..057887b82 100644
--- a/src/mixed_arena.h
+++ b/src/mixed_arena.h
@@ -263,12 +263,9 @@ public:
void operator=(SubType& other) { set(other); }
void swap(SubType& other) {
- data = other.data;
- usedElements = other.usedElements;
- allocatedElements = other.allocatedElements;
-
- other.data = nullptr;
- other.usedElements = other.allocatedElements = 0;
+ std::swap(data, other.data);
+ std::swap(usedElements, other.usedElements);
+ std::swap(allocatedElements, other.allocatedElements);
}
// iteration