diff options
author | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-13 14:57:51 +0000 |
---|---|---|
committer | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-13 14:57:51 +0000 |
commit | 836061bde615432d5dfcce8c26a23f217bfdbd29 (patch) | |
tree | e3ce26474403b1c8364ddaaeec4b55f1b46b162e /base/pickle.cc | |
parent | 954d58c4d2bd4499ed61da01ee22684669e12f28 (diff) | |
download | chromium_src-836061bde615432d5dfcce8c26a23f217bfdbd29.zip chromium_src-836061bde615432d5dfcce8c26a23f217bfdbd29.tar.gz chromium_src-836061bde615432d5dfcce8c26a23f217bfdbd29.tar.bz2 |
Don't cast negative values to unsigned. This eliminates warnings in GCC.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@799 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/pickle.cc')
-rw-r--r-- | base/pickle.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/base/pickle.cc b/base/pickle.cc index 356d5df..3c3c7e2 100644 --- a/base/pickle.cc +++ b/base/pickle.cc @@ -39,6 +39,9 @@ // static const int Pickle::kPayloadUnit = 64; +// We mark a read only pickle with a special capacity_. +static const size_t kCapacityReadOnly = std::numeric_limits<size_t>::max(); + // Payload is uint32 aligned. Pickle::Pickle() @@ -64,7 +67,7 @@ Pickle::Pickle(int header_size) Pickle::Pickle(const char* data, int data_len) : header_(reinterpret_cast<Header*>(const_cast<char*>(data))), header_size_(data_len - header_->payload_size), - capacity_(-1), + capacity_(kCapacityReadOnly), variable_buffer_offset_(0) { DCHECK(header_size_ >= sizeof(Header)); DCHECK(header_size_ == AlignInt(header_size_, sizeof(uint32))); @@ -82,12 +85,12 @@ Pickle::Pickle(const Pickle& other) } Pickle::~Pickle() { - if (capacity_ != -1) + if (capacity_ != kCapacityReadOnly) free(header_); } Pickle& Pickle::operator=(const Pickle& other) { - if (header_size_ != other.header_size_ && capacity_ != -1) { + if (header_size_ != other.header_size_ && capacity_ != kCapacityReadOnly) { free(header_); header_ = NULL; header_size_ = other.header_size_; @@ -258,7 +261,7 @@ void Pickle::EndWrite(char* dest, int length) { } bool Pickle::WriteBytes(const void* data, int data_len) { - DCHECK(capacity_ != -1) << "oops: pickle is readonly"; + DCHECK(capacity_ != kCapacityReadOnly) << "oops: pickle is readonly"; char* dest = BeginWrite(data_len); if (!dest) |