Fix memory buffer issues on gcc
This commit is contained in:
parent
872bef51bb
commit
8b3aed1f29
1 changed files with 12 additions and 8 deletions
|
@ -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) {}
|
||||||
|
|
||||||
|
|
Reference in a new issue