summaryrefslogtreecommitdiffstats
path: root/dec_stdout.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 15:39:57 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 15:39:57 +0000
commit231e63aa0df4768b134f65c272a33c6a123a36bb (patch)
treeaf4d9cab220d8e7056a5e8394ed23a01632fca17 /dec_stdout.cc
parentAdding debian version 1.2-3. (diff)
downloadplzip-231e63aa0df4768b134f65c272a33c6a123a36bb.tar.xz
plzip-231e63aa0df4768b134f65c272a33c6a123a36bb.zip
Merging upstream version 1.3~pre1.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'dec_stdout.cc')
-rw-r--r--dec_stdout.cc26
1 files changed, 10 insertions, 16 deletions
diff --git a/dec_stdout.cc b/dec_stdout.cc
index 7c5e51b..7af6b0d 100644
--- a/dec_stdout.cc
+++ b/dec_stdout.cc
@@ -46,6 +46,8 @@ struct Packet // data block
{
uint8_t * data; // data == 0 means end of member
int size; // number of bytes in data (if any)
+ explicit Packet( uint8_t * const d = 0, const int s = 0 )
+ : data( d ), size( s ) {}
};
@@ -211,21 +213,16 @@ extern "C" void * dworker_o( void * arg )
{
if( new_pos > 0 ) // make data packet
{
- Packet * opacket = new Packet;
- opacket->data = new_data;
- opacket->size = new_pos;
+ Packet * const opacket = new Packet( new_data, new_pos );
courier.collect_packet( opacket, worker_id );
new_pos = 0;
new_data = new( std::nothrow ) uint8_t[max_packet_size];
if( !new_data ) { pp( "Not enough memory." ); cleanup_and_fail(); }
}
if( LZ_decompress_finished( decoder ) == 1 )
- {
+ { // end of member token
+ courier.collect_packet( new Packet, worker_id );
LZ_decompress_reset( decoder ); // prepare for new member
- Packet * opacket = new Packet; // end of member token
- opacket->data = 0;
- opacket->size = 0;
- courier.collect_packet( opacket, worker_id );
break;
}
}
@@ -250,15 +247,12 @@ void muxer( Packet_courier & courier, const Pretty_print & pp, const int outfd )
{
while( true )
{
- Packet * opacket = courier.deliver_packet();
+ Packet * const opacket = courier.deliver_packet();
if( !opacket ) break; // queue is empty. all workers exited
- if( outfd >= 0 )
- {
- const int wr = writeblock( outfd, opacket->data, opacket->size );
- if( wr != opacket->size )
- { pp(); show_error( "Write error", errno ); cleanup_and_fail(); }
- }
+ const int wr = writeblock( outfd, opacket->data, opacket->size );
+ if( wr != opacket->size )
+ { pp(); show_error( "Write error", errno ); cleanup_and_fail(); }
delete[] opacket->data;
delete opacket;
}
@@ -311,7 +305,7 @@ int dec_stdout( const int num_workers, const int infd, const int outfd,
(double)out_size / in_size,
( 8.0 * in_size ) / out_size,
100.0 * ( 1.0 - ( (double)in_size / out_size ) ) );
- if( verbosity >= 3 )
+ if( verbosity >= 4 )
std::fprintf( stderr, "decompressed size %9llu, size %9llu. ",
out_size, in_size );