Avoid using streams in ELFIO to massively reduce the binary size

This commit is contained in:
Maschell
2023-01-04 15:05:26 +01:00
parent be5574ee9f
commit 333359c75d
11 changed files with 73 additions and 177 deletions

View File

@@ -1,23 +0,0 @@
#pragma once
#include <iostream>
struct membuf : std::streambuf {
membuf(char *begin, char *end) {
this->setg(begin, begin, end);
}
pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which = std::ios_base::in) override {
if (dir == std::ios_base::cur)
gbump(off);
else if (dir == std::ios_base::end)
setg(eback(), egptr() + off, egptr());
else if (dir == std::ios_base::beg)
setg(eback(), eback() + off, egptr());
return gptr() - eback();
}
pos_type seekpos(pos_type sp, std::ios_base::openmode which) override {
return seekoff(sp - pos_type(off_type(0)), std::ios_base::beg, which);
}
};

View File

@@ -34,7 +34,7 @@ public:
}
int z_ret;
z_stream s = {nullptr};
z_stream s = {};
s.zalloc = Z_NULL;
s.zfree = Z_NULL;
@@ -66,8 +66,8 @@ public:
return nullptr;
}
int z_ret = 0;
z_stream s = {nullptr};
int z_ret;
z_stream s = {};
s.zalloc = Z_NULL;
s.zfree = Z_NULL;