Lines Matching refs:pool
6 /* When DEBUG is enabled, Dovecot warns whenever a memory pool is grown.
7 This is done so that the initial pool size could be set large enough so that
17 typedef struct pool *pool_t;
20 const char *(*get_name)(pool_t pool);
22 void (*ref)(pool_t pool);
23 void (*unref)(pool_t *pool);
25 void *(*malloc)(pool_t pool, size_t size) ATTR_RETURNS_NONNULL;
26 void (*free)(pool_t pool, void *mem);
29 void *(*realloc)(pool_t pool, void *mem,
33 /* Frees all the memory in pool. NOTE: system_pool doesn't support
35 void (*clear)(pool_t pool);
39 size_t (*get_max_easy_alloc_size)(pool_t pool);
42 struct pool {
51 extern struct pool static_system_pool;
57 /* Create a new alloc-only pool. Note that `size' specifies the initial
60 /* Like alloconly pool, but clear the memory before freeing it. The idea is
62 pool, and be sure that it gets cleared from the memory when it's no longer
66 /* When allocating memory from returned pool, the data stack frame must be
71 /* Create new alloc pool. This is very similar to system pool, but it
75 /* Like alloc pool, but all memory is cleaned before freeing.
82 size_t pool_get_exp_grown_size(pool_t pool, size_t old_size, size_t min_size);
86 #define p_new(pool, type, count) \
87 ((type *) p_malloc(pool, MALLOC_MULTIPLY((unsigned int)sizeof(type), (count))) + \
90 #define p_realloc_type(pool, mem, type, old_count, new_count) \
91 ((type *) p_realloc(pool, mem, \
97 p_malloc(pool_t pool, size_t size)
99 return pool->v->malloc(pool, size);
103 p_realloc(pool_t pool, void *mem, size_t old_size, size_t new_size)
105 return pool->v->realloc(pool, mem, old_size, new_size);
110 #define p_free(pool, mem) \
112 p_free_internal(pool, mem); \
115 #define p_free_and_null(pool, mem) p_free(pool, mem)
117 static inline void p_free_internal(pool_t pool, void *mem)
119 pool->v->free(pool, mem);
122 static inline void p_clear(pool_t pool)
124 pool->v->clear(pool);
127 static inline size_t p_get_max_easy_alloc_size(pool_t pool)
129 return pool->v->get_max_easy_alloc_size(pool);
132 static inline const char *pool_get_name(pool_t pool)
134 return pool->v->get_name(pool);
137 static inline void pool_ref(pool_t pool)
139 pool->v->ref(pool);
142 static inline void pool_unref(pool_t *pool)
144 if (*pool != NULL)
145 (*pool)->v->unref(pool);
150 /* Returns how much memory has been allocated from this pool. */
151 size_t pool_alloconly_get_total_used_size(pool_t pool);
152 /* Returns how much system memory has been allocated for this pool. */
153 size_t pool_alloconly_get_total_alloc_size(pool_t pool);
155 /* Returns how much memory has been allocated from this pool. */
156 size_t pool_allocfree_get_total_used_size(pool_t pool);
157 /* Returns how much system memory has been allocated for this pool. */
158 size_t pool_allocfree_get_total_alloc_size(pool_t pool);
161 void pool_system_free(pool_t pool, void *mem);