Fix asserts with side-effects (per Keegan McAllister)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include <zlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "compressor.h"
|
||||
#include "dos_assert.h"
|
||||
|
||||
using namespace Network;
|
||||
using namespace std;
|
||||
@@ -9,18 +9,18 @@ using namespace std;
|
||||
string Compressor::compress_str( const string input )
|
||||
{
|
||||
long unsigned int len = BUFFER_SIZE;
|
||||
assert( Z_OK == compress( buffer, &len,
|
||||
reinterpret_cast<const unsigned char *>( input.data() ),
|
||||
input.size() ) );
|
||||
dos_assert( Z_OK == compress( buffer, &len,
|
||||
reinterpret_cast<const unsigned char *>( input.data() ),
|
||||
input.size() ) );
|
||||
return string( reinterpret_cast<char *>( buffer ), len );
|
||||
}
|
||||
|
||||
string Compressor::uncompress_str( const string input )
|
||||
{
|
||||
long unsigned int len = BUFFER_SIZE;
|
||||
assert( Z_OK == uncompress( buffer, &len,
|
||||
reinterpret_cast<const unsigned char *>( input.data() ),
|
||||
input.size() ) );
|
||||
dos_assert( Z_OK == uncompress( buffer, &len,
|
||||
reinterpret_cast<const unsigned char *>( input.data() ),
|
||||
input.size() ) );
|
||||
return string( reinterpret_cast<char *>( buffer ), len );
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "transportfragment.h"
|
||||
#include "transportinstruction.pb.h"
|
||||
#include "compressor.h"
|
||||
#include "fatal_assert.h"
|
||||
|
||||
using namespace Network;
|
||||
using namespace TransportBuffers;
|
||||
@@ -46,7 +47,7 @@ string Fragment::tostring( void )
|
||||
|
||||
ret += network_order_string( id );
|
||||
|
||||
assert( !( fragment_num & 0x8000 ) ); /* effective limit on size of a terminal screen change or buffered user input */
|
||||
fatal_assert( !( fragment_num & 0x8000 ) ); /* effective limit on size of a terminal screen change or buffered user input */
|
||||
uint16_t combined_fragment_num = ( final << 15 ) | fragment_num;
|
||||
ret += network_order_string( combined_fragment_num );
|
||||
|
||||
@@ -122,7 +123,7 @@ Instruction FragmentAssembly::get_assembly( void )
|
||||
}
|
||||
|
||||
Instruction ret;
|
||||
assert( ret.ParseFromString( get_compressor().uncompress_str( encoded ) ) );
|
||||
fatal_assert( ret.ParseFromString( get_compressor().uncompress_str( encoded ) ) );
|
||||
|
||||
fragments.clear();
|
||||
fragments_arrived = 0;
|
||||
|
||||
Reference in New Issue
Block a user