summaryrefslogtreecommitdiffstats
path: root/net/base/io_buffer.cc
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-10 18:51:34 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-10 18:51:34 +0000
commit776e175577badb594cc9023f56b16480546c94ea (patch)
treed4159651d2165dd6bbfbdae51faa4ac77404f870 /net/base/io_buffer.cc
parent62cf690a77564be902cf481803a9a7e3d52f7c55 (diff)
downloadchromium_src-776e175577badb594cc9023f56b16480546c94ea.zip
chromium_src-776e175577badb594cc9023f56b16480546c94ea.tar.gz
chromium_src-776e175577badb594cc9023f56b16480546c94ea.tar.bz2
After further discussion, do not try to handle memory errors, but make assertions about allocation parameters stronger.
BUG=25826 TEST=none Review URL: http://codereview.chromium.org/378037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31574 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/io_buffer.cc')
-rw-r--r--net/base/io_buffer.cc15
1 files changed, 6 insertions, 9 deletions
diff --git a/net/base/io_buffer.cc b/net/base/io_buffer.cc
index 9ae2746..4aa469a 100644
--- a/net/base/io_buffer.cc
+++ b/net/base/io_buffer.cc
@@ -19,20 +19,17 @@ void DrainableIOBuffer::SetOffset(int bytes) {
data_ = base_->data() + used_;
}
-bool GrowableIOBuffer::SetCapacity(int capacity) {
- DCHECK_GE(capacity, 0);
- char* cur_buf = real_data_.release();
- real_data_.reset(static_cast<char*>(realloc(cur_buf, capacity)));
- if (real_data_.get() == NULL && capacity != 0) {
- real_data_.reset(cur_buf);
- return false;
- }
+void GrowableIOBuffer::SetCapacity(int capacity) {
+ CHECK(capacity >= 0);
+ // realloc will crash if it fails.
+ real_data_.reset(static_cast<char*>(realloc(real_data_.release(), capacity)));
+ // Sanity check.
+ CHECK(real_data_.get() != NULL || capacity == 0);
capacity_ = capacity;
if (offset_ > capacity)
set_offset(capacity);
else
set_offset(offset_); // The pointer may have changed.
- return true;
}
void GrowableIOBuffer::set_offset(int offset) {