CLISH  0.7.3
blockpool.h
1 
22 /*---------------------------------------------------------------
23  * HISTORY
24  * 7-Dec-2004 Graeme McKerrell
25  * Updated to use the "lub" prefix
26  * 6-Feb-2004 Graeme McKerrell
27  * removed init_fn type definition and parameter, the client had
28  * more flexiblity in defining their own initialisation operation with
29  * arguments rather than use a "one-size-fits-all" approach.
30  * Modified blockpool structure to support FIFO block allocation.
31  * 23-Jan-2004 Graeme McKerrell
32  * Initial version
33  *---------------------------------------------------------------
34  * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
35  *--------------------------------------------------------------- */
36 #ifndef _lub_blockpool_h
37 #define _lub_blockpool_h
38 #include <stddef.h>
39 
40 /****************************************************************
41  * TYPE DEFINITIONS
42  **************************************************************** */
43 typedef struct _lub_blockpool_block lub_blockpool_block_t;
49 {
50  /* CLIENTS MUSTN'T TOUCH THESE DETAILS */
51  lub_blockpool_block_t *m_head;
52  lub_blockpool_block_t *m_tail;
53  size_t m_block_size;
54  size_t m_num_blocks;
55  unsigned m_alloc_blocks;
56  unsigned m_alloc_total_blocks;
57  unsigned m_alloc_hightide_blocks;
58  unsigned m_alloc_failures;
59 };
65 {
66  /*----------------------------------------------------- */
70  size_t block_size;
74  size_t num_blocks;
75  /*----------------------------------------------------- */
80  size_t alloc_blocks;
85  size_t alloc_bytes;
89  size_t free_blocks;
93  size_t free_bytes;
94  /*----------------------------------------------------- */
105  /*----------------------------------------------------- */
126  /*----------------------------------------------------- */
131  /*----------------------------------------------------- */
132 };
133 /****************************************************************
134  * BLOCKPOOL OPERATIONS
135  **************************************************************** */
147 extern void
152  lub_blockpool_t *blockpool,
156  void *memory,
160  size_t blocksize,
165  unsigned blockcount
166  );
167 
182 extern void *
187  lub_blockpool_t *blockpool
188  );
189 
201 extern void
206  lub_blockpool_t *blockpool,
210  void *block
211  );
223 void
228  lub_blockpool_t *instance,
232  lub_blockpool_stats_t *stats
233  );
234 
235 #endif /* _lub_blockpool_h */
236 
size_t alloc_bytes
Definition: blockpool.h:85
size_t alloc_hightide_bytes
Definition: blockpool.h:116
size_t alloc_total_blocks
Definition: blockpool.h:99
size_t free_blocks
Definition: blockpool.h:89
Definition: blockpool.h:64
void lub_blockpool__get_stats(lub_blockpool_t *instance, lub_blockpool_stats_t *stats)
size_t free_hightide_bytes
Definition: blockpool.h:125
void lub_blockpool_free(lub_blockpool_t *blockpool, void *block)
size_t alloc_total_bytes
Definition: blockpool.h:104
size_t free_hightide_blocks
Definition: blockpool.h:121
void lub_blockpool_init(lub_blockpool_t *blockpool, void *memory, size_t blocksize, unsigned blockcount)
void * lub_blockpool_alloc(lub_blockpool_t *blockpool)
size_t block_size
Definition: blockpool.h:70
Definition: blockpool.h:48
size_t alloc_hightide_blocks
Definition: blockpool.h:110
size_t free_bytes
Definition: blockpool.h:93
size_t alloc_blocks
Definition: blockpool.h:80
size_t num_blocks
Definition: blockpool.h:74
size_t alloc_failures
Definition: blockpool.h:130