Skip to content

Commit

Permalink
gzip: minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
widlarizer committed Jan 7, 2025
1 parent c1028be commit cfa3b71
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions kernel/gzip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,21 @@

YOSYS_NAMESPACE_BEGIN


#ifdef YOSYS_ENABLE_ZLIB

PRIVATE_NAMESPACE_BEGIN

using namespace Zlib;

PRIVATE_NAMESPACE_END

gzip_ostream::obuf::obuf() {
setp(buffer, buffer + buffer_size - 1);
}

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;
}

int gzip_ostream::obuf::sync() {
int num = pptr() - pbase();
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;
}
pbump(-num);
Expand All @@ -41,7 +34,7 @@ int gzip_ostream::obuf::sync() {
gzip_ostream::obuf::~obuf() {
if (gzf) {
sync();
gzclose(gzf);
Zlib::gzclose(gzf);
}
}

Expand Down

0 comments on commit cfa3b71

Please sign in to comment.