From 6bba9bf17b372bc3d9606aa0f165b2c2dfb37653 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Wed, 1 Jan 2014 13:11:16 -0700 Subject: [PATCH] Added MemBlob::appended() method. Handy during out-of-band buffer manipulation. --- src/MemBlob.cc | 8 ++++++++ src/MemBlob.h | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/MemBlob.cc b/src/MemBlob.cc index 3234215695..cc83aa9cd3 100644 --- a/src/MemBlob.cc +++ b/src/MemBlob.cc @@ -127,6 +127,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 804e0a6442..c4f0fa1fc3 100644 --- a/src/MemBlob.h +++ b/src/MemBlob.h @@ -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 * -- 2.47.3