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

Side by Side Diff: courgette/ensemble_apply.cc

Issue 6677141: Switch out use of std::string and std::vector for large allocations for a buffer class that doesn... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: fix linux build error. remove unnecessary call Created 9 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 | « courgette/encoded_program.cc ('k') | courgette/ensemble_create.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains the code to apply a Courgette patch. 5 // This file contains the code to apply a Courgette patch.
6 6
7 #include "courgette/ensemble.h" 7 #include "courgette/ensemble.h"
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 return C_READ_ERROR; 389 return C_READ_ERROR;
390 390
391 // Apply patch on streams. 391 // Apply patch on streams.
392 SourceStream old_source_stream; 392 SourceStream old_source_stream;
393 SourceStream patch_source_stream; 393 SourceStream patch_source_stream;
394 old_source_stream.Init(old_file.data(), old_file.length()); 394 old_source_stream.Init(old_file.data(), old_file.length());
395 patch_source_stream.Init(patch_file.data(), patch_file.length()); 395 patch_source_stream.Init(patch_file.data(), patch_file.length());
396 SinkStream new_sink_stream; 396 SinkStream new_sink_stream;
397 status = ApplyEnsemblePatch(&old_source_stream, &patch_source_stream, 397 status = ApplyEnsemblePatch(&old_source_stream, &patch_source_stream,
398 &new_sink_stream); 398 &new_sink_stream);
399 if (status != C_OK)
400 return status;
399 401
400 // Write the patched data to |new_file_name|. 402 // Write the patched data to |new_file_name|.
401 FilePath new_file_path(new_file_name); 403 FilePath new_file_path(new_file_name);
402 int written = 404 int written =
403 file_util::WriteFile( 405 file_util::WriteFile(
404 new_file_path, 406 new_file_path,
405 reinterpret_cast<const char*>(new_sink_stream.Buffer()), 407 reinterpret_cast<const char*>(new_sink_stream.Buffer()),
406 static_cast<int>(new_sink_stream.Length())); 408 static_cast<int>(new_sink_stream.Length()));
407 if (written == -1) 409 if (written == -1)
408 return C_WRITE_OPEN_ERROR; 410 return C_WRITE_OPEN_ERROR;
409 if (static_cast<size_t>(written) != new_sink_stream.Length()) 411 if (static_cast<size_t>(written) != new_sink_stream.Length())
410 return C_WRITE_ERROR; 412 return C_WRITE_ERROR;
411 413
412 return C_OK; 414 return C_OK;
413 } 415 }
414 416
415 } // namespace 417 } // namespace
OLDNEW
« no previous file with comments | « courgette/encoded_program.cc ('k') | courgette/ensemble_create.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698