Author: dreiss
Date: Wed Oct 6 17:10:51 2010
New Revision: 1005168
URL: http://svn.apache.org/viewvc?rev=1005168&view=rev
Log:
THRIFT-926. cpp: Let TMemoryBuffer::resetBuffer() set size of self-allocated
buffer
Although there is a constructor that allows a TMemoryBuffer to be
created with an internally-allocated buffer of a desired size, there was
no way for resetBuffer to obtain analogous behavior. This change causes
the appropriate constructor to be used.
Modified:
incubator/thrift/trunk/lib/cpp/src/transport/TBufferTransports.h
Modified: incubator/thrift/trunk/lib/cpp/src/transport/TBufferTransports.h
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/cpp/src/transport/TBufferTransports.h?rev=1005168&r1=1005167&r2=1005168&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/cpp/src/transport/TBufferTransports.h (original)
+++ incubator/thrift/trunk/lib/cpp/src/transport/TBufferTransports.h Wed Oct 6
17:10:51 2010
@@ -623,6 +623,15 @@ class TMemoryBuffer : public TVirtualTra
// Our old self gets destroyed.
}
+ /// See constructor documentation.
+ void resetBuffer(uint32_t sz) {
+ // Construct the new buffer.
+ TMemoryBuffer new_buffer(sz);
+ // Move it into ourself.
+ this->swap(new_buffer);
+ // Our old self gets destroyed.
+ }
+
std::string readAsString(uint32_t len) {
std::string str;
(void)readAppendToString(str, len);