From 7e729d207492f8b4be9509e927b687a282039bc9 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Wed, 6 Oct 2010 17:10:51 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005168 13f79535-47bb-0310-9956-ffa450edef68 --- lib/cpp/src/transport/TBufferTransports.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/cpp/src/transport/TBufferTransports.h b/lib/cpp/src/transport/TBufferTransports.h index 932d3bfe..f6d52d59 100644 --- a/lib/cpp/src/transport/TBufferTransports.h +++ b/lib/cpp/src/transport/TBufferTransports.h @@ -623,6 +623,15 @@ class TMemoryBuffer : public TVirtualTransport { // 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); -- 2.17.1