mirror of https://github.com/YosysHQ/yosys.git
gzip: minor refactor
This commit is contained in:
parent
5a5323a422
commit
5b70cea122
|
@ -15,28 +15,21 @@
|
||||||
|
|
||||||
YOSYS_NAMESPACE_BEGIN
|
YOSYS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
|
||||||
#ifdef YOSYS_ENABLE_ZLIB
|
#ifdef YOSYS_ENABLE_ZLIB
|
||||||
|
|
||||||
PRIVATE_NAMESPACE_BEGIN
|
|
||||||
|
|
||||||
using namespace Zlib;
|
|
||||||
|
|
||||||
PRIVATE_NAMESPACE_END
|
|
||||||
|
|
||||||
gzip_ostream::obuf::obuf() {
|
gzip_ostream::obuf::obuf() {
|
||||||
setp(buffer, buffer + buffer_size - 1);
|
setp(buffer, buffer + buffer_size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gzip_ostream::obuf::open(const std::string &filename) {
|
bool gzip_ostream::obuf::open(const std::string &filename) {
|
||||||
gzf = gzopen(filename.c_str(), "wb");
|
gzf = Zlib::gzopen(filename.c_str(), "wb");
|
||||||
return gzf != nullptr;
|
return gzf != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gzip_ostream::obuf::sync() {
|
int gzip_ostream::obuf::sync() {
|
||||||
int num = pptr() - pbase();
|
int num = pptr() - pbase();
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
if (gzwrite(gzf, reinterpret_cast<const void*>(pbase()), num) != num) {
|
if (Zlib::gzwrite(gzf, reinterpret_cast<const void*>(pbase()), num) != num) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pbump(-num);
|
pbump(-num);
|
||||||
|
@ -47,7 +40,7 @@ int gzip_ostream::obuf::sync() {
|
||||||
gzip_ostream::obuf::~obuf() {
|
gzip_ostream::obuf::~obuf() {
|
||||||
if (gzf) {
|
if (gzf) {
|
||||||
sync();
|
sync();
|
||||||
gzclose(gzf);
|
Zlib::gzclose(gzf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue