Lines Matching refs:arr
46 dePoolArray* arr = DE_POOL_NEW(pool, dePoolArray);
47 if (!arr)
51 memset(arr, 0, sizeof(dePoolArray));
52 arr->pool = pool;
53 arr->elementSize = elementSize;
55 return arr;
61 * \param arr Array pointer.
65 deBool dePoolArray_reserve (dePoolArray* arr, int size)
67 if (size >= arr->capacity)
75 if (arr->pageTableCapacity < reqPageTableCapacity)
77 int newPageTableCapacity = deMax32(2*arr->pageTableCapacity, reqPageTableCapacity);
78 void** newPageTable = (void**)deMemPool_alloc(arr->pool, newPageTableCapacity * sizeof(void*));
84 for (i = 0; i < arr->pageTableCapacity; i++)
85 newPageTable[i] = arr->pageTable[i];
91 oldPageTable = arr->pageTable;
92 oldPageTableSize = arr->pageTableCapacity * sizeof(void*);
94 arr->pageTable = newPageTable;
95 arr->pageTableCapacity = newPageTableCapacity;
100 int pageAllocSize = arr->elementSize << DE_ARRAY_ELEMENTS_PER_PAGE_LOG2;
101 int pageTableNdx = arr->capacity >> DE_ARRAY_ELEMENTS_PER_PAGE_LOG2;
107 DE_ASSERT(arr->pageTableCapacity > pageTableNdx); /* \todo [petri] is this always true? */
108 DE_ASSERT(!arr->pageTable[pageTableNdx]);
109 arr->pageTable[pageTableNdx++] = newPage;
118 void* newPage = deMemPool_alloc(arr->pool, pageAllocSize);
122 DE_ASSERT(!arr->pageTable[pageTableNdx]);
123 arr->pageTable[pageTableNdx] = newPage;
126 arr->capacity = pageTableNdx << DE_ARRAY_ELEMENTS_PER_PAGE_LOG2;
127 DE_ASSERT(arr->capacity >= newCapacity);
137 * \param arr Array pointer.
141 deBool dePoolArray_setSize (dePoolArray* arr, int size)
143 if (!dePoolArray_reserve(arr, size))
146 arr->numElements = size;
160 dePoolIntArray* arr = dePoolIntArray_create(pool);
170 dePoolIntArray_pushBack(arr, i);
174 DE_TEST_ASSERT(dePoolIntArray_getNumElements(arr) == 5000);
178 DE_TEST_ASSERT(dePoolIntArray_get(arr, i) == i);
185 DE_TEST_ASSERT(dePoolIntArray_popBack(arr) == (4999 - i));
189 DE_TEST_ASSERT(dePoolIntArray_getNumElements(arr) == 4000);
193 DE_TEST_ASSERT(dePoolIntArray_get(arr, i) == i);
198 dePoolIntArray_setSize(arr, 1000);
202 dePoolIntArray_pushBack(arr, i);
206 DE_TEST_ASSERT(dePoolIntArray_getNumElements(arr) == 5000);
210 DE_TEST_ASSERT(dePoolIntArray_get(arr, i) == i);
215 arr = dePoolIntArray_create(pool);
216 dePoolIntArray_setSize(arr, 1500);
217 dePoolIntArray_reserve(arr, 2000);
219 dePoolIntArray_set(arr, i, i);
221 dePoolIntArray_pushBack(arr, i);
223 DE_TEST_ASSERT(dePoolIntArray_getNumElements(arr) == 5000);
226 int val = dePoolIntArray_get(arr, i);