--------------------- PatchSet 2190 Date: 2001/05/02 13:49:06 Author: hno Branch: chunked_mempools Tag: (none) Log: Starting to document MemPools Members: doc/Programming-Guide/prog-guide.sgml:1.10.8.2->1.10.8.3 Index: squid/doc/Programming-Guide/prog-guide.sgml =================================================================== RCS file: /cvsroot/squid-sf//squid/doc/Programming-Guide/prog-guide.sgml,v retrieving revision 1.10.8.2 retrieving revision 1.10.8.3 diff -u -r1.10.8.2 -r1.10.8.3 --- squid/doc/Programming-Guide/prog-guide.sgml 29 Apr 2001 00:33:53 -0000 1.10.8.2 +++ squid/doc/Programming-Guide/prog-guide.sgml 2 May 2001 13:49:06 -0000 1.10.8.3 @@ -2,7 +2,7 @@
Squid Programmers Guide Duane Wessels, Squid Developers -$Id: prog-guide.sgml,v 1.10.8.2 2001/04/29 00:33:53 hno Exp $ +$Id: prog-guide.sgml,v 1.10.8.3 2001/05/02 13:49:06 hno Exp $ Squid is a WWW Cache application developed by the National Laboratory @@ -2986,4 +2986,66 @@ that pointer was last accessed. If there is a leak, then the bug occurs somewhere after that point of the code. +MemPools + +

+MemPools are a pooled memory allocator running on top of malloc(). It's +purpose is to reduce memory fragmentation and provide detailed statistics +on memory consumption. + +

+Preferably all memory allocations in Squid should be done using MemPools +or one of the types built on top of it (i.e. cbdata). + +

+Note: Usually it is better to use cbdata types as these gives you additional +safeguards in references and typechecking. However, for high usage pools where +the cbdata functionality of cbdata is not required directly using a MemPool +might be the way to go. + +Public API + +

+This defines the public API definitions + +createMemPool + +

+ + MemPool * pool = memPoolCreate(char *name, size_t element_size); + + +

+ Creates a MemPool of elements with the given size. + +memPoolAlloc + +

+ + type * data = memPoolAlloc(pool); + + +

+ Allocate one element from the pool + +memPoolFree + +

+ + memPoolFree(pool, data); + + +

+ Free a element allocated by memPoolAlloc(); + +memPoolDestroy + +

+ + memPoolDestroy(pool); + + +

+ Destroys a memory pool created by memPoolCreate(). +