Ignore:
Timestamp:
Jul 12, 2008 9:31:34 AM (16 years ago)
Author:
bennylp
Message:

Ticket 559 (minor): Update the pool alternative API (pool_alt.h) with the latest pool API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/include/pj/pool_alt.h

    r2039 r2123  
    2323 
    2424 
    25 typedef struct pj_pool_t pj_pool_t; 
    26  
    27  
    2825/** 
    2926 * The type for function to receive callback from the pool when it is unable 
     
    3330 */ 
    3431typedef void pj_pool_callback(pj_pool_t *pool, pj_size_t size); 
     32 
     33struct pj_pool_mem 
     34{ 
     35    struct pj_pool_mem *next; 
     36 
     37    /* data follows immediately */ 
     38}; 
     39 
     40 
     41typedef 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 
    3551 
    3652/** 
     
    106122 
    107123 
     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 */ 
     135typedef 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 
    108169typedef struct pj_pool_factory 
    109170{ 
     171    pj_pool_factory_policy policy; 
    110172    int dummy; 
    111173} pj_pool_factory; 
     
    121183#define pj_pool_factory_dump(pf, detail) 
    122184 
    123  
    124185#endif  /* __PJ_POOL_ALT_H__ */ 
    125186 
Note: See TracChangeset for help on using the changeset viewer.