Archived
1
Fork 0

Fix memory buffer issues on gcc

This commit is contained in:
Joshua Goins 2022-04-17 22:30:41 -04:00
parent 872bef51bb
commit 8b3aed1f29

View file

@ -3,6 +3,8 @@
#include <string_view> #include <string_view>
#include <streambuf> #include <streambuf>
#include <istream> #include <istream>
#include <memory>
#include <cstring>
enum class Seek { enum class Seek {
Current, Current,
@ -39,15 +41,7 @@ struct MemoryBuffer {
position = end; position = end;
} }
template <>
void write<std::vector<uint8_t>>(const std::vector<uint8_t>& t) {
size_t end = position + (sizeof(uint8_t) * t.size());
if(end > data.size())
data.resize(end);
data.insert(data.begin() + position, t.begin(), t.end());
position = end;
}
size_t size() const { size_t size() const {
return data.size(); return data.size();
@ -63,6 +57,16 @@ private:
size_t position = 0; size_t position = 0;
}; };
template<>
void MemoryBuffer::write<std::vector<uint8_t>>(const std::vector<uint8_t>& t) {
size_t end = position + (sizeof(uint8_t) * t.size());
if(end > data.size())
data.resize(end);
data.insert(data.begin() + position, t.begin(), t.end());
position = end;
}
struct MemorySpan { struct MemorySpan {
MemorySpan(const MemoryBuffer& new_buffer) : buffer(new_buffer) {} MemorySpan(const MemoryBuffer& new_buffer) : buffer(new_buffer) {}