]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Use size_t instead of int32_t for blob sizes
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 7 Jan 2013 19:08:33 +0000 (12:08 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 7 Jan 2013 19:08:33 +0000 (12:08 -0700)
because MemBlob only stores in-memory things and does not use negative sizes.

src/MemBlob.cc
src/MemBlob.h

index 8cb0c8044efef6fa27acc3d2a4946789f5f71c15..8c11841c9eba1a36931665a0683bb1d21db01cfb 100644 (file)
@@ -116,6 +116,14 @@ MemBlob::memAlloc(const size_type minSize)
     Stats.liveBytes += capacity;
 }
 
+void
+MemBlob::appended(const size_type n)
+{
+    Must(willFit(n));
+    size += n;
+    ++Stats.append;
+}
+
 void
 MemBlob::append(const char *source, const size_type n)
 {
index 7fe3b99990500a7e9ec3aab97303564796484909..fc15298b3ad1e1cd478f5a0db573e1e15410f9da 100644 (file)
@@ -66,7 +66,7 @@ class MemBlob: public RefCountable
 {
 public:
     typedef RefCount<MemBlob> Pointer;
-    typedef int32_t size_type;
+    typedef size_t size_type;
 
     MEMPROXY_CLASS(MemBlob);
 
@@ -95,6 +95,13 @@ public:
         return isAppendOffset(off) && willFit(n);
     }
 
+    /** adjusts internal object state as if exactly n bytes were append()ed
+     *
+     * \throw TextException if there was not enough space in the blob
+     * \param n the number of bytes that were appended
+     */
+    void appended(const size_type n);
+
     /** copies exactly n bytes from the source to the available space area,
      *  enlarging the used area by n bytes
      *