Lines Matching refs:pa
57 PoolAlloc* pa;
64 pa = alloc(cc, sizeof(*pa));
65 vg_assert(pa);
66 VG_(memset)(pa, 0, sizeof(*pa));
67 pa->nrRef = 0;
68 pa->elemSzB = elemSzB;
69 pa->nPerPool = nPerPool;
70 pa->pools = NULL;
71 pa->alloc = alloc;
72 pa->cc = cc;
73 pa->free = free_fn;
74 pa->pools = VG_(newXA)( alloc, cc, free_fn, sizeof(void*) );
75 pa->nextFree = NULL;
76 vg_assert(pa->pools);
77 return pa;
80 void VG_(deletePA) ( PoolAlloc* pa)
83 vg_assert(pa->nrRef == 0);
84 for (i = 0; i < VG_(sizeXA) (pa->pools); i++)
85 pa->free (*(UWord **)VG_(indexXA) ( pa->pools, i ));
86 VG_(deleteXA) (pa->pools);
87 pa->free (pa);
93 static void pal_add_new_pool ( PoolAlloc* pa )
97 vg_assert(pa);
98 vg_assert(pa->nextFree == NULL);
99 pool = pa->alloc( pa->cc, pa->elemSzB * pa->nPerPool );
104 for (i = pa->nPerPool-1; i >= 0; i--) {
105 UChar* elemC = ((UChar*)pool) + i * pa->elemSzB;
108 *elem = (UWord)pa->nextFree;
109 pa->nextFree = elem;
112 VG_(addToXA)( pa->pools, &pool );
115 void* VG_(allocEltPA) ( PoolAlloc* pa)
118 if (UNLIKELY(pa->nextFree == NULL)) {
119 pal_add_new_pool(pa);
121 elem = pa->nextFree;
122 pa->nextFree = (void*)*elem;
127 void VG_(freeEltPA) ( PoolAlloc* pa, void* p)
130 *elem = (UWord)pa->nextFree;
131 pa->nextFree = elem;
135 void VG_(addRefPA) ( PoolAlloc* pa)
137 pa->nrRef++;
140 UWord VG_(releasePA)(PoolAlloc* pa)
144 vg_assert(pa->nrRef > 0);
145 nrRef = --pa->nrRef;
147 VG_(deletePA)(pa);