Reduce allocated memory after read for BZ2

Reduce allocated memory after read for BZ2
This commit is contained in:
Andy Vandijck 2025-07-13 14:13:46 +02:00
parent b0820a28b6
commit 59fa419820
4 changed files with 10 additions and 2 deletions

View File

@ -68,6 +68,11 @@ blargg_err_t BZ2_Inflater::fill_buf( int count )
return blargg_ok;
}
blargg_err_t BZ2_Inflater::resize_buffer( int count )
{
return buf.resize(count);
}
blargg_err_t BZ2_Inflater::begin( callback_t new_callback, void* new_user_data,
int new_buf_size, int initial_read )
{

View File

@ -62,6 +62,8 @@ class BZ2_Inflater
return zbuf.total_out_lo32;
}
blargg_err_t resize_buffer(int count);
// Ends inflation and frees memory
void end();

View File

@ -67,6 +67,7 @@ blargg_err_t BZ2_Reader::read_v( void* out, int count )
if ( actual < count ) {
size_ = actual;
inflater.resize_buffer(actual);
set_remain(0);
}

View File

@ -203,11 +203,11 @@ BLARGG_EXPORT fex_err_t fex_identify_file( fex_type_t* type_out, const char path
{
char h [fex_identify_header_size];
RETURN_ERR( in.read( h, sizeof h ) );
type = fex_identify_extension( fex_identify_header( h ) );
}
}
*type_out = type;
return blargg_ok;
}