@@ -57,7 +57,7 @@ static tb_long_t xm_io_file_buffer_readline(tb_stream_ref_t stream, tb_buffer_re
5757 tb_hong_t size = tb_stream_size (stream );
5858 while (size < 0 || (offset = tb_stream_offset (stream )) < size )
5959 {
60- tb_long_t real = tb_stream_peek (stream , & data , TB_STREAM_BLOCK_MAXN );
60+ tb_long_t real = tb_stream_peek (stream , & data , XM_IO_BLOCK_MAXN );
6161 if (real > 0 )
6262 {
6363 tb_char_t const * e = tb_strnchr ((tb_char_t const * )data , real , '\n' );
@@ -184,12 +184,14 @@ static tb_int_t xm_io_file_read_all_directly(lua_State* lua, xm_io_file_t* file)
184184 if (!tb_buffer_init (& buf ))
185185 xm_io_return_error (lua , "init buffer failed!" );
186186
187+ tb_byte_t * data = tb_buffer_resize (& file -> rcache , XM_IO_BLOCK_MAXN );
188+ tb_assert (data );
189+
187190 // read all
188- tb_byte_t data [TB_STREAM_BLOCK_MAXN ];
189- tb_stream_ref_t stream = file -> u .file_ref ;
191+ tb_stream_ref_t stream = file -> u .file_ref ;
190192 while (!tb_stream_beof (stream ))
191193 {
192- tb_long_t real = tb_stream_read (stream , data , sizeof ( data ) );
194+ tb_long_t real = tb_stream_read (stream , data , XM_IO_BLOCK_MAXN );
193195 if (real > 0 )
194196 tb_buffer_memncat (& buf , data , real );
195197 else if (!real )
0 commit comments