diff options
Diffstat (limited to 'compress.cc')
-rw-r--r-- | compress.cc | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/compress.cc b/compress.cc index beae59e..af36f95 100644 --- a/compress.cc +++ b/compress.cc @@ -1,6 +1,6 @@ -/* Plzip - Parallel compressor compatible with lzip +/* Plzip - Massively parallel implementation of lzip Copyright (C) 2009 Laszlo Ersek. - Copyright (C) 2009-2018 Antonio Diaz Diaz. + Copyright (C) 2009-2019 Antonio Diaz Diaz. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,6 @@ #include <cstdio> #include <cstdlib> #include <cstring> -#include <queue> #include <string> #include <vector> #include <pthread.h> @@ -196,7 +195,7 @@ public: ocheck_counter( 0 ), owait_counter( 0 ), receive_id( 0 ), distrib_id( 0 ), deliver_id( 0 ), slot_tally( slots ), circular_ibuffer( slots ), - circular_obuffer( slots, (Packet *) 0 ), + circular_obuffer( slots, (const Packet *) 0 ), num_working( workers ), num_slots( slots ), eof( false ) { xinit_mutex( &imutex ); xinit_cond( &iav_or_eof ); @@ -318,7 +317,7 @@ struct Splitter_arg // courier for packaging and distribution to workers. extern "C" void * csplitter( void * arg ) { - const Splitter_arg & tmp = *(Splitter_arg *)arg; + const Splitter_arg & tmp = *(const Splitter_arg *)arg; Packet_courier & courier = *tmp.courier; const Pretty_print & pp = *tmp.pp; const int infd = tmp.infd; @@ -364,7 +363,7 @@ struct Worker_arg // them to courier. extern "C" void * cworker( void * arg ) { - const Worker_arg & tmp = *(Worker_arg *)arg; + const Worker_arg & tmp = *(const Worker_arg *)arg; Packet_courier & courier = *tmp.courier; const Pretty_print & pp = *tmp.pp; const int dictionary_size = tmp.dictionary_size; @@ -401,18 +400,15 @@ extern "C" void * cworker( void * arg ) int new_pos = 0; while( true ) { - if( LZ_compress_write_size( encoder ) > 0 ) + if( written < packet->size ) { - if( written < packet->size ) - { - const int wr = LZ_compress_write( encoder, - packet->data + offset + written, - packet->size - written ); - if( wr < 0 ) internal_error( "library error (LZ_compress_write)." ); - written += wr; - } - if( written >= packet->size ) LZ_compress_finish( encoder ); + const int wr = LZ_compress_write( encoder, + packet->data + offset + written, + packet->size - written ); + if( wr < 0 ) internal_error( "library error (LZ_compress_write)." ); + written += wr; } + if( written >= packet->size ) LZ_compress_finish( encoder ); const int rd = LZ_compress_read( encoder, packet->data + new_pos, offset + written - new_pos ); if( rd < 0 ) |