From fdd0082f8c0f02c29089c93e7b00ab4617b62c8a Mon Sep 17 00:00:00 2001 From: "wtc@chromium.org" Date: Mon, 13 Sep 2010 23:57:21 +0000 Subject: Fix nits: remove unnecessary local variable, check for null pointer before use, etc. R=mbelshe BUG=none TEST=none Review URL: http://codereview.chromium.org/3294020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59306 0039d316-1c4b-4281-b951-d872f2087c98 --- net/spdy/spdy_frame_builder.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'net') diff --git a/net/spdy/spdy_frame_builder.cc b/net/spdy/spdy_frame_builder.cc index 7d21b82..eed6eb2 100644 --- a/net/spdy/spdy_frame_builder.cc +++ b/net/spdy/spdy_frame_builder.cc @@ -104,7 +104,6 @@ bool SpdyFrameBuilder::ReadData(void** iter, const char** data, } char* SpdyFrameBuilder::BeginWrite(size_t length) { - size_t offset = length_; size_t needed_size = length_ + length; if (needed_size > capacity_ && !Resize(std::max(capacity_ * 2, needed_size))) return NULL; @@ -113,7 +112,7 @@ char* SpdyFrameBuilder::BeginWrite(size_t length) { DCHECK_LE(length, std::numeric_limits::max()); #endif - return buffer_ + offset; + return buffer_ + length_; } void SpdyFrameBuilder::EndWrite(char* dest, int length) { @@ -163,16 +162,16 @@ char* SpdyFrameBuilder::BeginWriteData(uint16 length) { } bool SpdyFrameBuilder::Resize(size_t new_capacity) { - if (new_capacity < capacity_) + if (new_capacity <= capacity_) return true; char* p = new char[new_capacity]; + if (!p) + return false; if (buffer_) { memcpy(p, buffer_, capacity_); delete[] buffer_; } - if (!p && new_capacity > 0) - return false; buffer_ = p; capacity_ = new_capacity; return true; -- cgit v1.1