mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-10-20 18:59:26 +02:00
[core/device_memory_manager] use more pointer/iterator stable std::vector<> instead of deque<> for multi address scatter/gather (#4098)
this SHOULD fix a specific issue where a deque can be reallocated causing spurious crashes Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4098 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
This commit is contained in:
parent
ae75ba4883
commit
29f712d3b5
1 changed files with 13 additions and 9 deletions
|
|
@ -11,6 +11,8 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <boost/container/deque.hpp>
|
||||||
|
|
||||||
#include "common/address_space.h"
|
#include "common/address_space.h"
|
||||||
#include "common/address_space.inc"
|
#include "common/address_space.inc"
|
||||||
#include "common/alignment.h"
|
#include "common/alignment.h"
|
||||||
|
|
@ -33,21 +35,23 @@ public:
|
||||||
|
|
||||||
void GatherValues(u32 start_entry, Common::ScratchBuffer<u32>& buffer) {
|
void GatherValues(u32 start_entry, Common::ScratchBuffer<u32>& buffer) {
|
||||||
buffer.resize(8);
|
buffer.resize(8);
|
||||||
buffer.resize(0);
|
const auto add_value = [&buffer](u32 value, size_t index) {
|
||||||
size_t index = 0;
|
if (buffer.size() < index + 1)
|
||||||
const auto add_value = [&](u32 value) {
|
buffer.resize(index + 8);
|
||||||
buffer.resize(index + 1);
|
|
||||||
buffer[index++] = value;
|
buffer[index++] = value;
|
||||||
|
return index;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
size_t index = 0;
|
||||||
u32 iter_entry = start_entry;
|
u32 iter_entry = start_entry;
|
||||||
Entry* current = &storage[iter_entry - 1];
|
Entry* current = &storage[iter_entry - 1];
|
||||||
add_value(current->value);
|
index = add_value(current->value, index);
|
||||||
while (current->next_entry != 0) {
|
while (current->next_entry != 0) {
|
||||||
iter_entry = current->next_entry;
|
iter_entry = current->next_entry;
|
||||||
current = &storage[iter_entry - 1];
|
current = &storage[iter_entry - 1];
|
||||||
add_value(current->value);
|
index = add_value(current->value, index);
|
||||||
}
|
}
|
||||||
|
buffer.resize(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Register(u32 value) {
|
u32 Register(u32 value) {
|
||||||
|
|
@ -124,8 +128,8 @@ private:
|
||||||
u32 value{};
|
u32 value{};
|
||||||
};
|
};
|
||||||
|
|
||||||
std::deque<Entry> storage;
|
std::vector<Entry> storage;
|
||||||
std::deque<u32> free_entries;
|
boost::container::deque<u32> free_entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EmptyAllocator {
|
struct EmptyAllocator {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue