diff options
author | Pixel <Pixel> | 2001-12-03 14:57:53 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2001-12-03 14:57:53 +0000 |
commit | ebdeb96f4f8275ab45cf9819cb3624dcf49a1b2b (patch) | |
tree | c87e4c54fc47e925455dfb497d4cdbfa045987d8 | |
parent | 8fac2c6298c5fd2b06e7e219687766dd8cf965b3 (diff) |
Zlib !@#!@#
-rw-r--r-- | include/Buffer.h | 4 | ||||
-rw-r--r-- | lib/Buffer.cc | 43 |
2 files changed, 1 insertions, 46 deletions
diff --git a/include/Buffer.h b/include/Buffer.h index 5177916..5b35139 100644 --- a/include/Buffer.h +++ b/include/Buffer.h @@ -21,12 +21,10 @@ class Buffer : public Handle { virtual String GetName(); virtual Buffer operator=(const Buffer &); virtual bool CanWatch(); - void deflate(void) throw (GeneralException); private: - char * buffer, * zbuffer; + char * buffer; int realsiz, bufsiz, ptr; - z_stream zs; }; #else diff --git a/lib/Buffer.cc b/lib/Buffer.cc index 2318f08..2c2c955 100644 --- a/lib/Buffer.cc +++ b/lib/Buffer.cc @@ -75,46 +75,3 @@ Buffer Buffer::operator=(const Buffer & b) { bool Buffer::CanWatch() { return false; } - -void Buffer::deflate(void) throw (GeneralException) { - int err; - - if (ptr) { - throw GeneralException(_("Can't deflate: buffer has already been read")); - } - - err = deflateInit(&zs, Z_BEST_COMPRESSION); - if (err != Z_OK) { - throw GeneralException(String(_("Can't init Zlib: ")) + zs.msg); - } - - zbuffer = (char *) malloc(realsiz); - - zs.next_in = (Bytef *) buffer; - zs.avail_in = realsiz; - zs.next_out = (Bytef *) zbuffer; - zs.avail_out = realsiz; - zs.zalloc = Z_NULL; - zs.zfree = Z_NULL; - zs.opaque = Z_NULL; - - err = ::deflate(&zs, Z_FINISH); - - if (err != Z_STREAM_END) { - throw GeneralException(String(_("Error during deflate: ")) + zs.msg); - } - - err = deflateEnd(&zs); - if (err != Z_OK) { - throw GeneralException(String(_("Error during deflateEnd: ")) + zs.msg); - } - - free(buffer); - buffer = zbuffer; - - realsiz = zs.total_out; - - int numblocks = realsiz / realloc_threshold; - int remains = realsiz % realloc_threshold; - buffer = (char *) realloc(buffer, bufsiz = ((numblocks + (remains ? 1 : 0)) * realloc_threshold)); -} |