00001
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef _lub_blockpool_h
00037 #define _lub_blockpool_h
00038 #include <stddef.h>
00039
00040
00041
00042
00043 typedef struct _lub_blockpool_block lub_blockpool_block_t;
00047 typedef struct _lub_blockpool lub_blockpool_t;
00048 struct _lub_blockpool
00049 {
00050
00051 lub_blockpool_block_t *m_head;
00052 lub_blockpool_block_t *m_tail;
00053 size_t m_block_size;
00054 size_t m_num_blocks;
00055 unsigned m_alloc_blocks;
00056 unsigned m_alloc_total_blocks;
00057 unsigned m_alloc_hightide_blocks;
00058 unsigned m_alloc_failures;
00059 };
00063 typedef struct _lub_blockpool_stats lub_blockpool_stats_t;
00064 struct _lub_blockpool_stats
00065 {
00066
00070 size_t block_size;
00074 size_t num_blocks;
00075
00080 size_t alloc_blocks;
00085 size_t alloc_bytes;
00089 size_t free_blocks;
00093 size_t free_bytes;
00094
00099 size_t alloc_total_blocks;
00104 size_t alloc_total_bytes;
00105
00110 size_t alloc_hightide_blocks;
00116 size_t alloc_hightide_bytes;
00121 size_t free_hightide_blocks;
00125 size_t free_hightide_bytes;
00126
00130 size_t alloc_failures;
00131
00132 };
00133
00134
00135
00147 extern void
00148 lub_blockpool_init(
00152 lub_blockpool_t *blockpool,
00156 void *memory,
00160 size_t blocksize,
00165 unsigned blockcount
00166 );
00167
00182 extern void *
00183 lub_blockpool_alloc(
00187 lub_blockpool_t *blockpool
00188 );
00189
00201 extern void
00202 lub_blockpool_free(
00206 lub_blockpool_t *blockpool,
00210 void *block
00211 );
00223 void
00224 lub_blockpool__get_stats(
00228 lub_blockpool_t *instance,
00232 lub_blockpool_stats_t *stats
00233 );
00234
00235 #endif
00236