From: Francesco Chemolli Date: Fri, 26 Jul 2013 15:28:41 +0000 (+0200) Subject: Decoupled reserveCapacity from reserveSpace. X-Git-Tag: SQUID_3_5_0_1~612^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=577bcebc6dd7f75846d3faea57b1803d9a23f4c4;p=thirdparty%2Fsquid.git Decoupled reserveCapacity from reserveSpace. --- diff --git a/src/SBuf.cc b/src/SBuf.cc index ae47f36eeb..9e76e4f4e2 100644 --- a/src/SBuf.cc +++ b/src/SBuf.cc @@ -183,14 +183,14 @@ SBuf::assign(const char *S, size_type n) void SBuf::reserveCapacity(size_type minCapacity) { - Must(0 <= minCapacity && minCapacity <= maxSize); - reserveSpace(minCapacity-length()); + Must(0 <= minCapacity); //upper bound checked in cow -> reAlloc + cow(minCapacity); } void SBuf::reserveSpace(size_type minSpace) { - Must(0 <= minSpace && minSpace <= maxSize); + Must(0 <= minSpace); //upper bound checked in cow -> reAlloc debugs(24, 7, "reserving " << minSpace << " for " << id); // we're not concerned about RefCounts here, // the store knows the last-used portion. If diff --git a/src/SBuf.h b/src/SBuf.h index 60708d3bba..e17677e67a 100644 --- a/src/SBuf.h +++ b/src/SBuf.h @@ -417,7 +417,8 @@ public: * * After this method is called, the SBuf is guaranteed to have at least * minCapacity bytes of total buffer size, including the currently-used - * portion + * portion; it is also guaranteed that after this call this SBuf + * has unique ownership of the underlying memory store. * \throw SBufTooBigException if the user tries to allocate too big a SBuf */ void reserveCapacity(size_type minCapacity);