Debian Codegraph @

generic/bltPool.h

raw symbols SCIP
1 #ifndef BLT_POOL_H
2 #define BLT_POOL_H
3
4 typedef 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
12 typedef struct Blt_PoolStruct *Blt_Pool;
13
14 typedef void *(Blt_PoolAllocProc) _ANSI_ARGS_((Blt_Pool pool, size_t size));
15 typedef void (Blt_PoolFreeProc) _ANSI_ARGS_((Blt_Pool pool, void *item));
16
17 struct 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
30 EXTERN Blt_Pool Blt_PoolCreate _ANSI_ARGS_((int type));
31 EXTERN 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 */