source: trunk/kitgen/8.x/blt/generic/bltPool.h@ 175

Last change on this file since 175 was 175, checked in by demin, 12 years ago

initial commit

File size: 1.2 KB
RevLine 
[175]1#ifndef BLT_POOL_H
2#define BLT_POOL_H
3
4typedef struct Blt_PoolChainStruct {
5 struct Blt_PoolChainStruct *nextPtr;
6} Blt_PoolChain;
7
8#define BLT_STRING_ITEMS 0
9#define BLT_FIXED_SIZE_ITEMS 1
10#define BLT_VARIABLE_SIZE_ITEMS 2
11
12typedef struct Blt_PoolStruct *Blt_Pool;
13
14typedef void *(Blt_PoolAllocProc) _ANSI_ARGS_((Blt_Pool pool, size_t size));
15typedef void (Blt_PoolFreeProc) _ANSI_ARGS_((Blt_Pool pool, void *item));
16
17struct Blt_PoolStruct {
18 Blt_PoolChain *headPtr; /* Chain of malloc'ed chunks. */
19 Blt_PoolChain *freePtr; /* List of deleted items. This is only used
20 * for fixed size items. */
21 size_t poolSize; /* Log2 of # of items in the current block. */
22 size_t itemSize; /* Size of an item. */
23 size_t bytesLeft; /* # of bytes left in the current chunk. */
24 size_t waste;
25
26 Blt_PoolAllocProc *allocProc;
27 Blt_PoolFreeProc *freeProc;
28};
29
30EXTERN Blt_Pool Blt_PoolCreate _ANSI_ARGS_((int type));
31EXTERN void Blt_PoolDestroy _ANSI_ARGS_((Blt_Pool pool));
32
33#define Blt_PoolAllocItem(poolPtr, n) (*((poolPtr)->allocProc))(poolPtr, n)
34#define Blt_PoolFreeItem(poolPtr, item) (*((poolPtr)->freeProc))(poolPtr, item)
35
36#endif /* BLT_POOL_H */
Note: See TracBrowser for help on using the repository browser.