File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,13 @@ void Block::addPointer(Pointer *P) {
31
31
P->Next = Pointers;
32
32
P->Prev = nullptr ;
33
33
Pointers = P;
34
+ #ifndef NDEBUG
35
+ assert (hasPointer (P));
36
+ #endif
34
37
}
35
38
36
39
void Block::removePointer (Pointer *P) {
40
+ assert (P->isBlockPointer ());
37
41
assert (P);
38
42
if (IsStatic) {
39
43
assert (!Pointers);
@@ -51,6 +55,10 @@ void Block::removePointer(Pointer *P) {
51
55
P->Prev ->Next = P->Next ;
52
56
if (P->Next )
53
57
P->Next ->Prev = P->Prev ;
58
+ P->PointeeStorage .BS .Pointee = nullptr ;
59
+ #ifndef NDEBUG
60
+ assert (!hasPointer (P));
61
+ #endif
54
62
}
55
63
56
64
void Block::cleanup () {
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ Pointer::~Pointer() {
60
60
61
61
if (Block *Pointee = PointeeStorage.BS .Pointee ) {
62
62
Pointee->removePointer (this );
63
+ PointeeStorage.BS .Pointee = nullptr ;
63
64
Pointee->cleanup ();
64
65
}
65
66
}
@@ -68,8 +69,15 @@ void Pointer::operator=(const Pointer &P) {
68
69
// If the current storage type is Block, we need to remove
69
70
// this pointer from the block.
70
71
if (isBlockPointer ()) {
72
+ if (P.isBlockPointer () && this ->block () == P.block ()) {
73
+ Offset = P.Offset ;
74
+ PointeeStorage.BS .Base = P.PointeeStorage .BS .Base ;
75
+ return ;
76
+ }
77
+
71
78
if (Block *Pointee = PointeeStorage.BS .Pointee ) {
72
79
Pointee->removePointer (this );
80
+ PointeeStorage.BS .Pointee = nullptr ;
73
81
Pointee->cleanup ();
74
82
}
75
83
}
@@ -96,8 +104,16 @@ void Pointer::operator=(Pointer &&P) {
96
104
// If the current storage type is Block, we need to remove
97
105
// this pointer from the block.
98
106
if (isBlockPointer ()) {
107
+ if (P.isBlockPointer () && this ->block () == P.block ()) {
108
+ Offset = P.Offset ;
109
+ PointeeStorage.BS .Base = P.PointeeStorage .BS .Base ;
110
+ return ;
111
+ }
112
+
99
113
if (Block *Pointee = PointeeStorage.BS .Pointee ) {
114
+ assert (P.block () != this ->block ());
100
115
Pointee->removePointer (this );
116
+ PointeeStorage.BS .Pointee = nullptr ;
101
117
Pointee->cleanup ();
102
118
}
103
119
}
You can’t perform that action at this time.
0 commit comments