ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/balloc.h
Revision: 1.1
Committed: Thu Jul 19 08:24:50 2007 UTC (16 years, 10 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Log Message:
initial import. the most important changes since Atheme are:
- fixed many memory leaks
- fixed many bugs
- converted to C++ and use more STL containers
- added a (not very enhanced yet) perl module
- greatly improved XML-RPC speed
- added a JSON-RPC module with code from json-cpp
- added a valgrind memcheck module to operserv
- added a more object oriented base64 implementation
- added a specialised unit test framework
- improved stability
- use gettimeofday() if available
- reworked adding/removing commands
- MemoServ IGNORE DEL can now remove indices

File Contents

# Content
1 /*
2 * Copyright © 2005 William Pitcock, et al.
3 * Rights to this code are as documented in doc/LICENSE.
4 *
5 * Data structures for the block allocator.
6 *
7 * $Id: balloc.h 7779 2007-03-03 13:55:42Z pippijn $
8 */
9
10 #ifndef BALLOC_H
11 #define BALLOC_H
12
13 struct Block
14 {
15 size_t alloc_size;
16 struct Block *next; /* Next in our chain of blocks */
17 void *elems; /* Points to allocated memory */
18 list_t free_list;
19 list_t used_list;
20 };
21
22 struct MemBlock
23 {
24 #ifdef DEBUG_BALLOC
25 unsigned long magic;
26 #endif
27 node_t self;
28 Block *block; /* Which block we belong to */
29 };
30
31 /* information for the root node of the heap */
32 struct BlockHeap
33 {
34 node_t hlist;
35 size_t elemSize; /* Size of each element to be stored */
36 unsigned long elemsPerBlock; /* Number of elements per block */
37 unsigned long blocksAllocated; /* Number of blocks allocated */
38 unsigned long freeElems; /* Number of free elements */
39 Block *base; /* Pointer to first block */
40 };
41
42 E int BlockHeapFree (BlockHeap *bh, void *ptr);
43 E void *BlockHeapAlloc (BlockHeap *bh);
44
45 E BlockHeap *BlockHeapCreate (size_t elemsize, int elemsperblock);
46 E int BlockHeapDestroy (BlockHeap *bh);
47
48 E void initBlockHeap (void);
49 E void BlockHeapUsage (BlockHeap *bh, size_t * bused, size_t * bfree, size_t * bmemusage);
50
51 #endif