mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-11 07:03:33 +02:00
Debugger: Reduce meminfo block check hazard.
If a debugger (i.e. the memory view) checks for memory block info while a save state is being loaded, it can crash. This was already rare, but this change makes it significantly rarer. Of course, it's still possible without a mutex, but I'm wanting to avoid slowing down the lookups as they are used at runtime within emulation.
This commit is contained in:
@@ -162,7 +162,9 @@ void MemSlabMap::DoState(PointerWrap &p) {
|
||||
|
||||
int count = 0;
|
||||
if (p.mode == p.MODE_READ) {
|
||||
Clear();
|
||||
// Since heads_ is a static size, let's avoid clearing it.
|
||||
// This helps in case a debugger call happens concurrently.
|
||||
Slab *old = first_;
|
||||
Do(p, count);
|
||||
|
||||
first_ = new Slab();
|
||||
@@ -170,7 +172,6 @@ void MemSlabMap::DoState(PointerWrap &p) {
|
||||
lastFind_ = first_;
|
||||
--count;
|
||||
|
||||
heads_.resize(SLICES, nullptr);
|
||||
FillHeads(first_);
|
||||
|
||||
Slab *slab = first_;
|
||||
@@ -183,6 +184,13 @@ void MemSlabMap::DoState(PointerWrap &p) {
|
||||
|
||||
FillHeads(slab);
|
||||
}
|
||||
|
||||
// Now that it's entirely disconnected, delete the old slabs.
|
||||
while (old != nullptr) {
|
||||
Slab *next = old->next;
|
||||
delete old;
|
||||
old = next;
|
||||
}
|
||||
} else {
|
||||
for (Slab *slab = first_; slab != nullptr; slab = slab->next)
|
||||
++count;
|
||||
|
||||
Reference in New Issue
Block a user