Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(973)

Side by Side Diff: runtime/bin/filter.cc

Issue 14241021: Fix Zlib filters to correctly emit the last chunks of data. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/standalone/io/regress_10026_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 #include "bin/filter.h" 6 #include "bin/filter.h"
7 #include "bin/io_buffer.h" 7 #include "bin/io_buffer.h"
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 10
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 return true; 271 return true;
272 } 272 }
273 273
274 274
275 intptr_t ZLibInflateFilter::Processed(uint8_t* buffer, 275 intptr_t ZLibInflateFilter::Processed(uint8_t* buffer,
276 intptr_t length, 276 intptr_t length,
277 bool flush) { 277 bool flush) {
278 stream_.avail_out = length; 278 stream_.avail_out = length;
279 stream_.next_out = buffer; 279 stream_.next_out = buffer;
280 switch (inflate(&stream_, flush ? Z_SYNC_FLUSH : Z_NO_FLUSH)) { 280 switch (inflate(&stream_, flush ? Z_SYNC_FLUSH : Z_NO_FLUSH)) {
281 case Z_STREAM_END:
282 case Z_BUF_ERROR:
281 case Z_OK: { 283 case Z_OK: {
282 intptr_t processed = length - stream_.avail_out; 284 intptr_t processed = length - stream_.avail_out;
283 if (processed == 0) { 285 if (processed == 0) {
284 delete[] current_buffer_; 286 delete[] current_buffer_;
285 current_buffer_ = NULL; 287 current_buffer_ = NULL;
286 return 0; 288 return 0;
287 } else { 289 } else {
288 // We processed data, should be called again. 290 // We processed data, should be called again.
289 return processed; 291 return processed;
290 } 292 }
291 } 293 }
292 294
293 case Z_STREAM_END:
294 case Z_BUF_ERROR:
295 // We processed all available input data.
296 delete[] current_buffer_;
297 current_buffer_ = NULL;
298 return 0;
299
300 default: 295 default:
301 case Z_MEM_ERROR: 296 case Z_MEM_ERROR:
302 case Z_NEED_DICT: 297 case Z_NEED_DICT:
303 case Z_DATA_ERROR: 298 case Z_DATA_ERROR:
304 case Z_STREAM_ERROR: 299 case Z_STREAM_ERROR:
305 // An error occoured. 300 // An error occoured.
306 delete[] current_buffer_; 301 delete[] current_buffer_;
307 current_buffer_ = NULL; 302 current_buffer_ = NULL;
308 return -1; 303 return -1;
309 } 304 }
310 } 305 }
311 306
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/regress_10026_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698