@@ -105,10 +105,10 @@ static VALUE
105
105
no_compress (struct streaming_compress_t * sc , ZSTD_EndDirective endOp )
106
106
{
107
107
ZSTD_inBuffer input = { NULL , 0 , 0 };
108
- const char * output_data = RSTRING_PTR (sc -> buf );
109
108
VALUE result = rb_str_new (0 , 0 );
110
109
size_t ret ;
111
110
do {
111
+ const char * output_data = RSTRING_PTR (sc -> buf );
112
112
ZSTD_outBuffer output = { (void * )output_data , sc -> buf_size , 0 };
113
113
114
114
ret = zstd_stream_compress (sc -> ctx , & output , & input , endOp , false);
@@ -131,9 +131,9 @@ rb_streaming_compress_compress(VALUE obj, VALUE src)
131
131
struct streaming_compress_t * sc ;
132
132
TypedData_Get_Struct (obj , struct streaming_compress_t , & streaming_compress_type , sc );
133
133
134
- const char * output_data = RSTRING_PTR (sc -> buf );
135
134
VALUE result = rb_str_new (0 , 0 );
136
135
while (input .pos < input .size ) {
136
+ const char * output_data = RSTRING_PTR (sc -> buf );
137
137
ZSTD_outBuffer output = { (void * )output_data , sc -> buf_size , 0 };
138
138
size_t const ret = zstd_stream_compress (sc -> ctx , & output , & input , ZSTD_e_continue , false);
139
139
if (ZSTD_isError (ret )) {
@@ -150,7 +150,6 @@ rb_streaming_compress_write(int argc, VALUE *argv, VALUE obj)
150
150
size_t total = 0 ;
151
151
struct streaming_compress_t * sc ;
152
152
TypedData_Get_Struct (obj , struct streaming_compress_t , & streaming_compress_type , sc );
153
- const char * output_data = RSTRING_PTR (sc -> buf );
154
153
155
154
while (argc -- > 0 ) {
156
155
VALUE str = * argv ++ ;
@@ -161,6 +160,7 @@ rb_streaming_compress_write(int argc, VALUE *argv, VALUE obj)
161
160
VALUE result = rb_str_new (0 , 0 );
162
161
163
162
while (input .pos < input .size ) {
163
+ const char * output_data = RSTRING_PTR (sc -> buf );
164
164
ZSTD_outBuffer output = { (void * )output_data , sc -> buf_size , 0 };
165
165
size_t const ret = zstd_stream_compress (sc -> ctx , & output , & input , ZSTD_e_continue , false);
166
166
if (ZSTD_isError (ret )) {
0 commit comments