@@ -105,10 +105,10 @@ static VALUE
105105no_compress (struct streaming_compress_t * sc , ZSTD_EndDirective endOp )
106106{
107107 ZSTD_inBuffer input = { NULL , 0 , 0 };
108- const char * output_data = RSTRING_PTR (sc -> buf );
109108 VALUE result = rb_str_new (0 , 0 );
110109 size_t ret ;
111110 do {
111+ const char * output_data = RSTRING_PTR (sc -> buf );
112112 ZSTD_outBuffer output = { (void * )output_data , sc -> buf_size , 0 };
113113
114114 ret = zstd_stream_compress (sc -> ctx , & output , & input , endOp , false);
@@ -131,9 +131,9 @@ rb_streaming_compress_compress(VALUE obj, VALUE src)
131131 struct streaming_compress_t * sc ;
132132 TypedData_Get_Struct (obj , struct streaming_compress_t , & streaming_compress_type , sc );
133133
134- const char * output_data = RSTRING_PTR (sc -> buf );
135134 VALUE result = rb_str_new (0 , 0 );
136135 while (input .pos < input .size ) {
136+ const char * output_data = RSTRING_PTR (sc -> buf );
137137 ZSTD_outBuffer output = { (void * )output_data , sc -> buf_size , 0 };
138138 size_t const ret = zstd_stream_compress (sc -> ctx , & output , & input , ZSTD_e_continue , false);
139139 if (ZSTD_isError (ret )) {
@@ -150,7 +150,6 @@ rb_streaming_compress_write(int argc, VALUE *argv, VALUE obj)
150150 size_t total = 0 ;
151151 struct streaming_compress_t * sc ;
152152 TypedData_Get_Struct (obj , struct streaming_compress_t , & streaming_compress_type , sc );
153- const char * output_data = RSTRING_PTR (sc -> buf );
154153
155154 while (argc -- > 0 ) {
156155 VALUE str = * argv ++ ;
@@ -161,6 +160,7 @@ rb_streaming_compress_write(int argc, VALUE *argv, VALUE obj)
161160 VALUE result = rb_str_new (0 , 0 );
162161
163162 while (input .pos < input .size ) {
163+ const char * output_data = RSTRING_PTR (sc -> buf );
164164 ZSTD_outBuffer output = { (void * )output_data , sc -> buf_size , 0 };
165165 size_t const ret = zstd_stream_compress (sc -> ctx , & output , & input , ZSTD_e_continue , false);
166166 if (ZSTD_isError (ret )) {
0 commit comments