Index: samples/shell.cc |
diff --git a/samples/shell.cc b/samples/shell.cc |
index 0a9b8a0d4f899ba423af2eafd4135341dada952f..7fc284a66d4686096d5a8b31c8412737397c7b12 100644 |
--- a/samples/shell.cc |
+++ b/samples/shell.cc |
@@ -45,6 +45,12 @@ |
#include "../src/v8.h" |
#endif // USING_V8_SHARED |
+// Natives decompressor is a part of V8 sources because it is used in |
+// mksnapshot. |
+#ifdef COMPRESS_STARTUP_DATA_BZ2 |
+#include "../src/bz2-decompress.h" |
+#endif |
+ |
#if !defined(_WIN32) && !defined(_WIN64) |
#include <unistd.h> // NOLINT |
#endif |
@@ -303,29 +309,13 @@ int main(int argc, char* argv[]) { |
} |
#ifdef COMPRESS_STARTUP_DATA_BZ2 |
- ASSERT_EQ(v8::StartupData::kBZip2, |
- v8::V8::GetCompressedStartupDataAlgorithm()); |
- int compressed_data_count = v8::V8::GetCompressedStartupDataCount(); |
- v8::StartupData* compressed_data = new v8::StartupData[compressed_data_count]; |
- v8::V8::GetCompressedStartupData(compressed_data); |
- for (int i = 0; i < compressed_data_count; ++i) { |
- char* decompressed = new char[compressed_data[i].raw_size]; |
- unsigned int decompressed_size = compressed_data[i].raw_size; |
- int result = |
- BZ2_bzBuffToBuffDecompress(decompressed, |
- &decompressed_size, |
- const_cast<char*>(compressed_data[i].data), |
- compressed_data[i].compressed_size, |
- 0, 1); |
- if (result != BZ_OK) { |
- fprintf(stderr, "bzip error code: %d\n", result); |
- exit(1); |
- } |
- compressed_data[i].data = decompressed; |
- compressed_data[i].raw_size = decompressed_size; |
+ BZip2Decompressor startup_data_decompressor; |
Vitaly Repeshko
2011/06/06 15:59:15
It seems unfortunate that the shell sample is usin
|
+ int bz2_result = startup_data_decompressor.DecompressStartupData(); |
+ if (bz2_result != BZ_OK) { |
+ fprintf(stderr, "bzip error code: %d\n", bz2_result); |
+ exit(1); |
} |
- v8::V8::SetDecompressedStartupData(compressed_data); |
-#endif // COMPRESS_STARTUP_DATA_BZ2 |
+#endif |
v8::V8::SetFlagsFromCommandLine(&argc, argv, true); |
int result = 0; |
@@ -348,13 +338,6 @@ int main(int argc, char* argv[]) { |
} |
v8::V8::Dispose(); |
-#ifdef COMPRESS_STARTUP_DATA_BZ2 |
- for (int i = 0; i < compressed_data_count; ++i) { |
- delete[] compressed_data[i].data; |
- } |
- delete[] compressed_data; |
-#endif // COMPRESS_STARTUP_DATA_BZ2 |
- |
return result; |
} |