Lines Matching defs:pool

58 #define COUNT(pool,what)  (pool)->stats.what++
60 #define COUNT(pool,what) /* nothing */
108 PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align)
116 pool->mask = PR_BITMASK(PR_CeilingLog2(align));
117 pool->first.next = NULL;
118 pool->first.base = pool->first.avail = pool->first.limit =
119 (PRUword)PL_ARENA_ALIGN(pool, &pool->first + 1);
120 pool->current = &pool->first;
121 pool->arenasize = size;
123 memset(&pool->stats, 0, sizeof pool->stats);
124 pool->stats.name = strdup(name);
125 pool->stats.next = arena_stats_list;
126 arena_stats_list = &pool->stats;
132 ** PL_ArenaAllocate() -- allocate space from an arena pool
135 ** pool.
138 ** pool->current.
140 ** If there is not enough space in the arena pool->current, try
157 PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
162 PR_ASSERT((nb & pool->mask) == 0);
164 nb = (PRUword)PL_ARENA_ALIGN(pool, nb); /* force alignment */
166 /* attempt to allocate from arenas at pool->current */
168 a = pool->current;
171 pool->current = a;
197 /* the newly allocated arena is linked after pool->current
198 * and becomes pool->current */
199 a->next = pool->current->next;
200 pool->current->next = a;
201 pool->current = a;
202 if ( NULL == pool->first.next )
203 pool->first.next = a;
212 PRUint32 sz = PR_MAX(pool->arenasize, nb);
213 sz += sizeof *a + pool->mask; /* header and alignment slop */
217 a->base = a->avail = (PRUword)PL_ARENA_ALIGN(pool, a + 1);
220 /* the newly allocated arena is linked after pool->current
221 * and becomes pool->current */
222 a->next = pool->current->next;
223 pool->current->next = a;
224 pool->current = a;
225 if ( NULL == pool->first.next )
226 pool->first.next = a;
227 PL_COUNT_ARENA(pool,++);
228 COUNT(pool, nmallocs);
238 PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr)
242 PL_ARENA_ALLOCATE(newp, pool, size + incr);
250 * Reset pool->current to point to head in case it pointed at a tail arena.
252 static void FreeArenaList(PLArenaPool *pool, PLArena *head, PRBool reallyFree)
274 PL_COUNT_ARENA(pool,--);
289 pool->current = head;
292 PR_IMPLEMENT(void) PL_ArenaRelease(PLArenaPool *pool, char *mark)
296 for (a = pool->first.next; a; a = a->next) {
298 a->avail = (PRUword)PL_ARENA_ALIGN(pool, mark);
299 FreeArenaList(pool, a, PR_FALSE);
305 PR_IMPLEMENT(void) PL_FreeArenaPool(PLArenaPool *pool)
307 FreeArenaList(pool, &pool->first, PR_FALSE);
308 COUNT(pool, ndeallocs);
311 PR_IMPLEMENT(void) PL_FinishArenaPool(PLArenaPool *pool)
313 FreeArenaList(pool, &pool->first, PR_TRUE);
318 if (pool->stats.name)
319 PR_DELETE(pool->stats.name);
322 if (stats == &pool->stats) {
363 PR_IMPLEMENT(void) PL_ArenaCountAllocation(PLArenaPool *pool, PRUint32 nb)
365 pool->stats.nallocs++;
366 pool->stats.nbytes += nb;
367 if (nb > pool->stats.maxalloc)
368 pool->stats.maxalloc = nb;
369 pool->stats.variance += nb * nb;
373 PLArenaPool *pool, PRUint32 size, PRUint32 incr)
375 pool->stats.ninplace++;
379 PLArenaPool *pool, PRUint32 size, PRUint32 incr)
381 pool->stats.ngrows++;
382 pool->stats.nbytes += incr;
383 pool->stats.variance -= size * size;
385 if (size > pool->stats.maxalloc)
386 pool->stats.maxalloc = size;
387 pool->stats.variance += size * size;
390 PR_IMPLEMENT(void) PL_ArenaCountRelease(PLArenaPool *pool, char *mark)
392 pool->stats.nreleases++;
395 PR_IMPLEMENT(void) PL_ArenaCountRetract(PLArenaPool *pool, char *mark)
397 pool->stats.nfastrels++;