]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/sbuf/MemBlob.cc
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / sbuf / MemBlob.cc
index b488eafbe191e8add96154279e81891591cd7e7a..dd72ce429a466b5716b7444f86e79c62ec954f95 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -9,8 +9,8 @@
 #include "squid.h"
 #include "base/TextException.h"
 #include "Debug.h"
+#include "sbuf/DetailedStats.h"
 #include "sbuf/MemBlob.h"
-#include "SBufDetailedStats.h"
 
 #include <iostream>
 
@@ -124,6 +124,27 @@ MemBlob::append(const char *source, const size_type n)
     ++Stats.append;
 }
 
+void
+MemBlob::syncSize(const size_type n)
+{
+    debugs(MEMBLOB_DEBUGSECTION, 7, n << " was: " << size);
+    Must(LockCount() <= 1);
+    Must(n <= size);
+    size = n;
+}
+
+void
+MemBlob::consume(const size_type rawN)
+{
+    if (rawN && size) {
+        Must(LockCount() <= 1);
+        const auto n = std::min(rawN, size);
+        size -= n;
+        if (size)
+            memmove(mem, mem + n, size);
+    }
+}
+
 const MemBlobStats&
 MemBlob::GetStats()
 {