Include dependency graph for MemBuf.cc:
![](MemBuf_8cc__incl.png)
Go to the source code of this file.
Macros | |
#define | MEM_BUF_INIT_SIZE (2*1024) |
#define | MEM_BUF_MAX_SIZE (2*1000*1024*1024) |
Functions | |
void | memBufReport (MemBuf *mb) |
Macro Definition Documentation
◆ MEM_BUF_INIT_SIZE
#define MEM_BUF_INIT_SIZE (2*1024) |
* Rationale: * ---------- * * Here is how one would Comm::Write an object without MemBuffer: * * { * -- allocate: * buf = malloc(big_enough); * * -- "pack": * snprintf object(s) piece-by-piece constantly checking for overflows * and maintaining (buf+offset); * ... * * -- write * Comm::Write(buf, free, ...); * } * * The whole "packing" idea is quite messy: We are given a buffer of fixed * size and we have to check all the time that we still fit. Sounds logical. * * However, what happens if we have more data? If we are lucky to stop before * we overrun any buffers, we still may have garbage (e.g. half of ETag) in * the buffer. * * MemBuffer: * ---------- * * MemBuffer is a memory-resident buffer with printf()-like interface. It * hides all offset handling and overflow checking. Moreover, it has a * built-in control that no partial data has been written. * * MemBuffer is designed to handle relatively small data. It starts with a * small buffer of configurable size to avoid allocating huge buffers all the * time. MemBuffer doubles the buffer when needed. It assert()s that it will * not grow larger than a configurable limit. MemBuffer has virtually no * overhead (and can even reduce memory consumption) compared to old * "packing" approach. * * MemBuffer eliminates both "packing" mess and truncated data: * * { * -- setup * MemBuf buf; * * -- required init with optional size tuning (see #defines for defaults) * buf.init(initial-size, absolute-maximum); * * -- "pack" (no need to handle offsets or check for overflows) * buf.Printf(...); * ... * * -- write * Comm::Write(fd, buf, callback); * * -- *iff* you did not give the buffer away, free it yourself * -- buf.clean(); * }
◆ MEM_BUF_MAX_SIZE
Function Documentation
◆ memBufReport()
Introduction
- About Squid
- Why Squid?
- Squid Developers
- How to Donate
- How to Help Out
- Getting Squid
- Squid Source Packages
- Squid Deployment Case-Studies
- Squid Software Foundation
Documentation
- Quick Setup
- Configuration:
- FAQ and Wiki
- Guide Books:
- Non-English
- More...
Support
- Security Advisories
- Bugzilla Database
- Mailing lists
- Contacting us
- Commercial services
- Project Sponsors
- Squid-based products