Changeset 2123 for pjproject/trunk/pjlib/include/pj/pool_alt.h
- Timestamp:
- Jul 12, 2008 9:31:34 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/pool_alt.h
r2039 r2123 23 23 24 24 25 typedef struct pj_pool_t pj_pool_t;26 27 28 25 /** 29 26 * The type for function to receive callback from the pool when it is unable … … 33 30 */ 34 31 typedef void pj_pool_callback(pj_pool_t *pool, pj_size_t size); 32 33 struct pj_pool_mem 34 { 35 struct pj_pool_mem *next; 36 37 /* data follows immediately */ 38 }; 39 40 41 typedef struct pj_pool_t 42 { 43 struct pj_pool_mem *first_mem; 44 pj_pool_factory *factory; 45 char obj_name[32]; 46 pj_size_t used_size; 47 pj_pool_callback *cb; 48 } pj_pool_t; 49 50 35 51 36 52 /** … … 106 122 107 123 124 #define PJ_POOL_ZALLOC_T(pool,type) \ 125 ((type*)pj_pool_zalloc(pool, sizeof(type))) 126 #define PJ_POOL_ALLOC_T(pool,type) \ 127 ((type*)pj_pool_alloc(pool, sizeof(type))) 128 #ifndef PJ_POOL_ALIGNMENT 129 # define PJ_POOL_ALIGNMENT 4 130 #endif 131 132 /** 133 * This structure declares pool factory interface. 134 */ 135 typedef struct pj_pool_factory_policy 136 { 137 /** 138 * Allocate memory block (for use by pool). This function is called 139 * by memory pool to allocate memory block. 140 * 141 * @param factory Pool factory. 142 * @param size The size of memory block to allocate. 143 * 144 * @return Memory block. 145 */ 146 void* (*block_alloc)(pj_pool_factory *factory, pj_size_t size); 147 148 /** 149 * Free memory block. 150 * 151 * @param factory Pool factory. 152 * @param mem Memory block previously allocated by block_alloc(). 153 * @param size The size of memory block. 154 */ 155 void (*block_free)(pj_pool_factory *factory, void *mem, pj_size_t size); 156 157 /** 158 * Default callback to be called when memory allocation fails. 159 */ 160 pj_pool_callback *callback; 161 162 /** 163 * Option flags. 164 */ 165 unsigned flags; 166 167 } pj_pool_factory_policy; 168 108 169 typedef struct pj_pool_factory 109 170 { 171 pj_pool_factory_policy policy; 110 172 int dummy; 111 173 } pj_pool_factory; … … 121 183 #define pj_pool_factory_dump(pf, detail) 122 184 123 124 185 #endif /* __PJ_POOL_ALT_H__ */ 125 186
Note: See TracChangeset
for help on using the changeset viewer.