From 28658b28eea506af35897723adb7c69e67327351 Mon Sep 17 00:00:00 2001 From: "vandebo@chromium.org" Date: Wed, 28 Oct 2009 00:01:33 +0000 Subject: Handle out of memory in GrowableIOBuffer more gracefully. BUG=25826 TEST=none Review URL: http://codereview.chromium.org/338049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30287 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/io_buffer.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'net/base/io_buffer.h') diff --git a/net/base/io_buffer.h b/net/base/io_buffer.h index eaf3a39..e301df8 100644 --- a/net/base/io_buffer.h +++ b/net/base/io_buffer.h @@ -106,12 +106,14 @@ class GrowableIOBuffer : public IOBuffer { GrowableIOBuffer() : IOBuffer(), capacity_(0), offset_(0) {} ~GrowableIOBuffer() { data_ = NULL; } + // realloc memory to the specified capacity. Returns true on success. + // On failure, the capacity and buffer are unchanged. + bool SetCapacity(int capacity); int capacity() { return capacity_; } - void set_capacity(int capacity); // |offset| moves the |data_| pointer, allowing "seeking" in the data. - int offset() { return offset_; } void set_offset(int offset); + int offset() { return offset_; } int RemainingCapacity() { return capacity_ - offset_; } char* StartOfBuffer() { return real_data_.get(); } -- cgit v1.1