~redstrate/libxiv

8b3aed1f29d210a029cd62a6e59bf43db5ce516c — Joshua Goins 2 years ago 872bef5
Fix memory buffer issues on gcc
1 files changed, 12 insertions(+), 8 deletions(-)

M include/memorybuffer.h
M include/memorybuffer.h => include/memorybuffer.h +12 -8
@@ 3,6 3,8 @@
#include <string_view>
#include <streambuf>
#include <istream>
#include <memory>
#include <cstring>

enum class Seek {
    Current,


@@ 39,15 41,7 @@ struct MemoryBuffer {
        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 {
        return data.size();


@@ 63,6 57,16 @@ private:
    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 {
    MemorySpan(const MemoryBuffer& new_buffer) : buffer(new_buffer) {}