From: Alex Rousskov Date: Mon, 7 Jan 2013 19:08:33 +0000 (-0700) Subject: Use size_t instead of int32_t for blob sizes X-Git-Tag: SQUID_3_5_0_1~444^2~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5072445eae219ff2e5062c65f8ff57a6c7240b3b;p=thirdparty%2Fsquid.git Use size_t instead of int32_t for blob sizes because MemBlob only stores in-memory things and does not use negative sizes. --- diff --git a/src/MemBlob.cc b/src/MemBlob.cc index 8cb0c8044e..8c11841c9e 100644 --- a/src/MemBlob.cc +++ b/src/MemBlob.cc @@ -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) { diff --git a/src/MemBlob.h b/src/MemBlob.h index 7fe3b99990..fc15298b3a 100644 --- a/src/MemBlob.h +++ b/src/MemBlob.h @@ -66,7 +66,7 @@ class MemBlob: public RefCountable { public: typedef RefCount 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 *