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

Unified Diff: runtime/bin/filter.cc

Issue 22867033: Update ZLib/GZip in dart:io to be a Codec/Converter from dart:convert. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/bin/filter_patch.dart » ('j') | sdk/lib/io/data_transformer.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/filter.cc
diff --git a/runtime/bin/filter.cc b/runtime/bin/filter.cc
index 43b08e7ff4d86343fb745b3fe6d4f640013223d7..0babea9e5f2a74bda8806d75470383a6a26cc503 100644
--- a/runtime/bin/filter.cc
+++ b/runtime/bin/filter.cc
@@ -82,19 +82,22 @@ void FUNCTION_NAME(Filter_Process)(Dart_NativeArguments args) {
Dart_Handle filter_obj = Dart_GetNativeArgument(args, 0);
Filter* filter = GetFilter(filter_obj);
Dart_Handle data_obj = Dart_GetNativeArgument(args, 1);
+ intptr_t start = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
+ intptr_t end = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3));
+ intptr_t chunk_length = end - start;
intptr_t length;
Dart_TypedData_Type type;
uint8_t* buffer = NULL;
Dart_Handle result = Dart_TypedDataAcquireData(
data_obj, &type, reinterpret_cast<void**>(&buffer), &length);
if (!Dart_IsError(result)) {
- uint8_t* zlib_buffer = new uint8_t[length];
+ uint8_t* zlib_buffer = new uint8_t[chunk_length];
if (zlib_buffer == NULL) {
Dart_TypedDataReleaseData(data_obj);
Dart_ThrowException(DartUtils::NewInternalError(
"Failed to allocate buffer for zlib"));
}
- memmove(zlib_buffer, buffer, length);
+ memmove(zlib_buffer, buffer + start, chunk_length);
Dart_TypedDataReleaseData(data_obj);
buffer = zlib_buffer;
} else {
@@ -102,15 +105,16 @@ void FUNCTION_NAME(Filter_Process)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Failed to get list length"));
}
- buffer = new uint8_t[length];
- if (Dart_IsError(Dart_ListGetAsBytes(data_obj, 0, buffer, length))) {
+ buffer = new uint8_t[chunk_length];
+ if (Dart_IsError(Dart_ListGetAsBytes(
+ data_obj, start, buffer, chunk_length))) {
delete[] buffer;
Dart_ThrowException(DartUtils::NewInternalError(
"Failed to get list bytes"));
}
}
// Process will take ownership of buffer, if successful.
- if (!filter->Process(buffer, length)) {
+ if (!filter->Process(buffer, chunk_length)) {
delete[] buffer;
EndFilter(filter_obj, filter);
Dart_ThrowException(DartUtils::NewInternalError(
« no previous file with comments | « no previous file | runtime/bin/filter_patch.dart » ('j') | sdk/lib/io/data_transformer.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698