* Rationale:
* ----------
*
- * Here is how one would comm_write an object without MemBuffer:
+ * Here is how one would Comm::Write an object without MemBuffer:
*
* {
* -- allocate:
* ...
*
* -- write
- * comm_write(buf, free, ...);
+ * Comm::Write(buf, free, ...);
* }
*
* The whole "packing" idea is quite messy: We are given a buffer of fixed
* ...
*
* -- write
- * comm_write_mbuf(fd, buf, handler, data);
+ * Comm::Write(fd, buf, callback);
*
* -- *iff* you did not give the buffer away, free it yourself
* -- buf.clean();
\endverbatim
*/
-/* if you have configure you can use this */
-#if defined(HAVE_CONFIG_H)
-#include "config.h"
-#endif
+#include "squid.h"
+#include "MemBuf.h"
+#include "profiler/Profiler.h"
+#include "protos.h"
#ifdef VA_COPY
#undef VA_COPY
#define VA_COPY __va_copy
#endif
-#include "squid.h"
-#include "MemBuf.h"
-
/* local constants */
/* default values for buffer sizes, used by memBufDefInit */
init(MEM_BUF_INIT_SIZE, MEM_BUF_MAX_SIZE);
}
-
/** init with specific sizes */
void
MemBuf::init(mb_size_t szInit, mb_size_t szMax)
PROF_start(MemBuf_consume);
if (shiftSize > 0) {
if (shiftSize < cSize)
- xmemmove(buf, buf + shiftSize, cSize - shiftSize);
+ memmove(buf, buf + shiftSize, cSize - shiftSize);
size -= shiftSize;
PROF_stop(MemBuf_consume);
}
+// removes last tailSize bytes
+void MemBuf::truncate(mb_size_t tailSize)
+{
+ const mb_size_t cSize = contentSize();
+ assert(0 <= tailSize && tailSize <= cSize);
+ assert(!stolen); /* not frozen */
+ size -= tailSize;
+}
+
/**
* calls memcpy, appends exactly size bytes,
* extends buffer or creates buffer if needed.
grow(size + sz + 1);
assert(size + sz <= capacity); /* paranoid */
-
- xmemcpy(space(), newContent, sz);
-
+ memcpy(space(), newContent, sz);
appended(sz);
}
PROF_stop(MemBuf_append);
va_end(args);
}
-
/**
* vPrintf for other printf()'s to use; calls vsnprintf, extends buf if needed
*/
if (!size || buf[size - 1]) {
assert(!buf[size]);
} else {
- size--;
+ --size;
}
}
PROF_stop(MemBuf_grow);
}
-
/* Reports */
/**
mb->Printf("memBufReport is not yet implemented @?@\n");
}
-#ifndef _USE_INLINE_
+#if !_USE_INLINE_
#include "MemBuf.cci"
#endif