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

Side by Side Diff: base/pickle.cc

Issue 165435: Merge 22826 - Add short circuit case for self assignment, and add virtual des... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/pickle.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/base/pickle.cc:r22826
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "base/pickle.h" 5 #include "base/pickle.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 CHECK(resized); // Realloc failed. 58 CHECK(resized); // Realloc failed.
59 memcpy(header_, other.header_, payload_size); 59 memcpy(header_, other.header_, payload_size);
60 } 60 }
61 61
62 Pickle::~Pickle() { 62 Pickle::~Pickle() {
63 if (capacity_ != kCapacityReadOnly) 63 if (capacity_ != kCapacityReadOnly)
64 free(header_); 64 free(header_);
65 } 65 }
66 66
67 Pickle& Pickle::operator=(const Pickle& other) { 67 Pickle& Pickle::operator=(const Pickle& other) {
68 if (this == &other) {
69 NOTREACHED();
70 return *this;
71 }
68 if (capacity_ == kCapacityReadOnly) { 72 if (capacity_ == kCapacityReadOnly) {
69 header_ = NULL; 73 header_ = NULL;
70 capacity_ = 0; 74 capacity_ = 0;
71 } 75 }
72 if (header_size_ != other.header_size_) { 76 if (header_size_ != other.header_size_) {
73 free(header_); 77 free(header_);
74 header_ = NULL; 78 header_ = NULL;
75 header_size_ = other.header_size_; 79 header_size_ = other.header_size_;
76 } 80 }
77 bool resized = Resize(header_size_ + other.header_->payload_size); 81 bool resized = Resize(other.header_size_ + other.header_->payload_size);
78 CHECK(resized); // Realloc failed. 82 CHECK(resized); // Realloc failed.
79 memcpy(header_, other.header_, header_size_ + other.header_->payload_size); 83 memcpy(header_, other.header_,
84 other.header_size_ + other.header_->payload_size);
80 variable_buffer_offset_ = other.variable_buffer_offset_; 85 variable_buffer_offset_ = other.variable_buffer_offset_;
81 return *this; 86 return *this;
82 } 87 }
83 88
84 bool Pickle::ReadBool(void** iter, bool* result) const { 89 bool Pickle::ReadBool(void** iter, bool* result) const {
85 DCHECK(iter); 90 DCHECK(iter);
86 91
87 int tmp; 92 int tmp;
88 if (!ReadInt(iter, &tmp)) 93 if (!ReadInt(iter, &tmp))
89 return false; 94 return false;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 DCHECK(header_size <= static_cast<size_t>(kPayloadUnit)); 392 DCHECK(header_size <= static_cast<size_t>(kPayloadUnit));
388 393
389 const Header* hdr = reinterpret_cast<const Header*>(start); 394 const Header* hdr = reinterpret_cast<const Header*>(start);
390 const char* payload_base = start + header_size; 395 const char* payload_base = start + header_size;
391 const char* payload_end = payload_base + hdr->payload_size; 396 const char* payload_end = payload_base + hdr->payload_size;
392 if (payload_end < payload_base) 397 if (payload_end < payload_base)
393 return NULL; 398 return NULL;
394 399
395 return (payload_end > end) ? NULL : payload_end; 400 return (payload_end > end) ? NULL : payload_end;
396 } 401 }
OLDNEW
« no previous file with comments | « base/pickle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698