]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Decoupled reserveCapacity from reserveSpace.
authorFrancesco Chemolli <kinkie@squid-cache.org>
Fri, 26 Jul 2013 15:28:41 +0000 (17:28 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Fri, 26 Jul 2013 15:28:41 +0000 (17:28 +0200)
src/SBuf.cc
src/SBuf.h

index ae47f36eeb4739440d1db82765ad870a0b44b141..9e76e4f4e23bf76935a773d65d856c1a9c5261e4 100644 (file)
@@ -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
index 60708d3bbae3e9dac6caea0130dd4b7d2c3a4693..e17677e67a74cabb14d1b88dc2fb91908c7146fd 100644 (file)
@@ -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);