Lines Matching refs:pa
57 PoolAlloc* pa; in VG_() local
64 pa = alloc_fn(cc, sizeof(*pa)); in VG_()
65 VG_(memset)(pa, 0, sizeof(*pa)); in VG_()
66 pa->nrRef = 0; in VG_()
67 pa->elemSzB = elemSzB; in VG_()
68 pa->nPerPool = nPerPool; in VG_()
69 pa->pools = NULL; in VG_()
70 pa->alloc_fn = alloc_fn; in VG_()
71 pa->cc = cc; in VG_()
72 pa->free_fn = free_fn; in VG_()
73 pa->pools = VG_(newXA)( alloc_fn, cc, free_fn, sizeof(void*) ); in VG_()
74 pa->nextFree = NULL; in VG_()
76 return pa; in VG_()
79 void VG_(deletePA) ( PoolAlloc* pa) in VG_()
82 vg_assert(pa->nrRef == 0); in VG_()
83 for (i = 0; i < VG_(sizeXA) (pa->pools); i++) in VG_()
84 pa->free_fn (*(UWord **)VG_(indexXA) ( pa->pools, i )); in VG_()
85 VG_(deleteXA) (pa->pools); in VG_()
86 pa->free_fn (pa); in VG_()
92 static void pal_add_new_pool ( PoolAlloc* pa ) in pal_add_new_pool() argument
96 vg_assert(pa); in pal_add_new_pool()
97 vg_assert(pa->nextFree == NULL); in pal_add_new_pool()
98 pool = pa->alloc_fn( pa->cc, pa->elemSzB * pa->nPerPool ); in pal_add_new_pool()
102 for (i = pa->nPerPool-1; i >= 0; i--) { in pal_add_new_pool()
103 UChar* elemC = ((UChar*)pool) + i * pa->elemSzB; in pal_add_new_pool()
106 *elem = (UWord)pa->nextFree; in pal_add_new_pool()
107 pa->nextFree = elem; in pal_add_new_pool()
110 VG_(addToXA)( pa->pools, &pool ); in pal_add_new_pool()
113 UWord VG_(sizePA) ( PoolAlloc* pa) in VG_()
115 vg_assert(pa); in VG_()
116 return pa->nPerPool * VG_(sizeXA) (pa->pools); in VG_()
119 void* VG_(allocEltPA) ( PoolAlloc* pa) in VG_()
122 if (UNLIKELY(pa->nextFree == NULL)) { in VG_()
123 pal_add_new_pool(pa); in VG_()
125 elem = pa->nextFree; in VG_()
126 pa->nextFree = (void*)*elem; in VG_()
131 void VG_(freeEltPA) ( PoolAlloc* pa, void* p) in VG_()
134 *elem = (UWord)pa->nextFree; in VG_()
135 pa->nextFree = elem; in VG_()
139 void VG_(addRefPA) ( PoolAlloc* pa) in VG_()
141 pa->nrRef++; in VG_()
144 UWord VG_(releasePA)(PoolAlloc* pa) in VG_()
148 vg_assert(pa->nrRef > 0); in VG_()
149 nrRef = --pa->nrRef; in VG_()
151 VG_(deletePA)(pa); in VG_()