Lines Matching refs:cell

170 static Cell *DLAddFront(Cell * list, Cell * cell)  in DLAddFront()  argument
172 cell->next = list; in DLAddFront()
173 cell->prev = NULL; in DLAddFront()
176 list->prev = cell; in DLAddFront()
178 return cell; in DLAddFront()
191 static Cell *DLLookup(Cell * list, Cell * cell) in DLLookup() argument
195 if (list == cell) in DLLookup()
215 static Cell *DLExtract(Cell * list, Cell * cell) in DLExtract() argument
217 if (cell->next) in DLExtract()
219 cell->next->prev = cell->prev; in DLExtract()
222 if (cell->prev == NULL) in DLExtract()
224 return cell->next; in DLExtract()
228 cell->prev->next = cell->next; in DLExtract()
245 static Cell *DLInsert(Cell * list, Cell * cell) in DLInsert() argument
252 if (cell <= next) in DLInsert()
258 cell->next = next; in DLInsert()
259 cell->prev = prev; in DLInsert()
262 next->prev = cell; in DLInsert()
263 if ((char *)cell + cell->size == (char *)next) in DLInsert()
266 cell->size += next->size; in DLInsert()
267 cell->next = next = next->next; in DLInsert()
270 next->prev = cell; in DLInsert()
276 prev->next = cell; in DLInsert()
277 if ((char *)prev + prev->size == (char *)cell) in DLInsert()
280 prev->size += cell->size; in DLInsert()
291 return cell; // cell becomes new head of list in DLInsert()
309 Cell *cell; in DLOverlap() local
311 for (cell = list; cell; cell = cell->next) in DLOverlap()
313 if (RangeOverlap(cell, (char *)cell + cell->size, start, end)) in DLOverlap()
332 Cell *cell; in DLSize() local
335 for (cell = list; cell; cell = cell->next) in DLSize()
337 size += cell->size; in DLSize()
360 Cell *cell; // candidate block in OS_AllocFromHeap() local
401 for (cell = hd->free; cell != NULL; cell = cell->next) in OS_AllocFromHeap()
403 if ((long)size <= cell->size) in OS_AllocFromHeap()
409 if (cell == NULL) in OS_AllocFromHeap()
418 SDK_ASSERTMSG(OFFSET(cell, ALIGNMENT) == 0, OS_ERR_ALLOCFROMHEAP_BROKENHEAP); in OS_AllocFromHeap()
419 SDK_ASSERTMSG(cell->hd == NULL, OS_ERR_ALLOCFROMHEAP_BROKENHEAP); in OS_AllocFromHeap()
421 leftoverSize = cell->size - (long)size; in OS_AllocFromHeap()
425 hd->free = DLExtract(hd->free, cell); in OS_AllocFromHeap()
430 cell->size = (long)size; in OS_AllocFromHeap()
433 newCell = (Cell *) ((char *)cell + size); in OS_AllocFromHeap()
440 newCell->prev = cell->prev; in OS_AllocFromHeap()
441 newCell->next = cell->next; in OS_AllocFromHeap()
454 SDK_ASSERTMSG(hd->free == cell, OS_ERR_ALLOCFROMHEAP_BROKENHEAP); in OS_AllocFromHeap()
460 hd->allocated = DLAddFront(hd->allocated, cell); in OS_AllocFromHeap()
463 cell->hd = hd; in OS_AllocFromHeap()
464 cell->requested = requested; in OS_AllocFromHeap()
466 hd->paddingBytes += cell->size - (HEADERSIZE + requested); in OS_AllocFromHeap()
472 return (void *)((char *)cell + HEADERSIZE); in OS_AllocFromHeap()
494 Cell *cell; // object iterator in OS_AllocFixed() local
548 for (cell = hd->free; cell; cell = cell->next) in OS_AllocFixed()
550 void *cellEnd = (char *)cell + cell->size; in OS_AllocFixed()
557 if ((char *)end <= (char *)cell) in OS_AllocFixed()
562 if (InRange(cell, (char *)start - HEADERSIZE, end) && in OS_AllocFixed()
565 if ((char *)cell < (char *)start) in OS_AllocFixed()
566 start = (void *)cell; in OS_AllocFixed()
571 hd->free = DLExtract(hd->free, cell); // Note cell->next is intact. XXX in OS_AllocFixed()
572 hd->size -= cell->size; // Update stats in OS_AllocFixed()
576 if (InRange(cell, (char *)start - HEADERSIZE, end)) in OS_AllocFixed()
578 if ((char *)cell < (char *)start) in OS_AllocFixed()
580 start = (void *)cell; in OS_AllocFixed()
592 newCell->next = cell->next; in OS_AllocFixed()
597 newCell->prev = cell->prev; in OS_AllocFixed()
606 hd->size -= (char *)end - (char *)cell; in OS_AllocFixed()
618 SDK_ASSERT(MINOBJSIZE <= (char *)start - (char *)cell); in OS_AllocFixed()
620 cell->size = (char *)start - (char *)cell; in OS_AllocFixed()
631 newCell->next = cell->next; in OS_AllocFixed()
636 newCell->prev = cell; in OS_AllocFixed()
637 cell->next = newCell; // cell is before newCell in OS_AllocFixed()
638 cell->size = (char *)start - (char *)cell; in OS_AllocFixed()
671 Cell *cell; in OS_FreeToHeap() local
692 cell = (Cell *) ((char *)ptr - HEADERSIZE); in OS_FreeToHeap()
695 SDK_ASSERTMSG(cell->hd == hd, OS_ERR_FREETOHEAP_INVPTR); in OS_FreeToHeap()
696 SDK_ASSERTMSG(DLLookup(hd->allocated, cell), OS_ERR_FREETOHEAP_INVPTR); in OS_FreeToHeap()
699 cell->hd = NULL; in OS_FreeToHeap()
701 hd->paddingBytes -= cell->size - (HEADERSIZE + cell->requested); in OS_FreeToHeap()
702 hd->payloadBytes -= cell->requested; in OS_FreeToHeap()
706 hd->allocated = DLExtract(hd->allocated, cell); in OS_FreeToHeap()
709 hd->free = DLInsert(hd->free, cell); in OS_FreeToHeap()
728 Cell *cell; in OS_FreeAllToHeap() local
746 while ((cell = hd->allocated) != NULL) in OS_FreeAllToHeap()
748 SDK_ASSERT(cell->hd == hd); in OS_FreeAllToHeap()
749 SDK_ASSERT(DLLookup(hd->allocated, cell)); in OS_FreeAllToHeap()
752 cell->hd = NULL; in OS_FreeAllToHeap()
754 hd->paddingBytes -= cell->size - (HEADERSIZE + cell->requested); in OS_FreeAllToHeap()
755 hd->payloadBytes -= cell->requested; in OS_FreeAllToHeap()
759 hd->allocated = DLExtract(hd->allocated, cell); in OS_FreeAllToHeap()
762 hd->free = DLInsert(hd->free, cell); in OS_FreeAllToHeap()
905 Cell *cell; in OS_CreateHeap() local
948 cell = (Cell *) start; in OS_CreateHeap()
949 cell->prev = NULL; in OS_CreateHeap()
950 cell->next = NULL; in OS_CreateHeap()
951 cell->size = hd->size; in OS_CreateHeap()
953 cell->hd = NULL; in OS_CreateHeap()
956 hd->free = cell; in OS_CreateHeap()
1050 Cell *cell; in OS_AddToHeap() local
1091 cell = (Cell *) start; in OS_AddToHeap()
1092 cell->size = (char *)end - (char *)start; in OS_AddToHeap()
1094 cell->hd = NULL; in OS_AddToHeap()
1098 hd->size += cell->size; in OS_AddToHeap()
1099 hd->free = DLInsert(hd->free, cell); in OS_AddToHeap()
1153 Cell *cell; in OS_CheckHeap() local
1178 for (cell = hd->allocated; cell; cell = cell->next) in OS_CheckHeap()
1180 OSi_CHECK(InRange(cell, heapInfo->arenaStart, heapInfo->arenaEnd)); in OS_CheckHeap()
1181 OSi_CHECK(OFFSET(cell, ALIGNMENT) == 0); in OS_CheckHeap()
1182 OSi_CHECK(cell->next == NULL || cell->next->prev == cell); in OS_CheckHeap()
1183 OSi_CHECK(MINOBJSIZE <= cell->size); in OS_CheckHeap()
1184 OSi_CHECK(OFFSET(cell->size, ALIGNMENT) == 0); in OS_CheckHeap()
1186 total += cell->size; in OS_CheckHeap()
1190 OSi_CHECK(cell->hd == hd); in OS_CheckHeap()
1191 OSi_CHECK(HEADERSIZE + cell->requested <= cell->size); in OS_CheckHeap()
1196 for (cell = hd->free; cell; cell = cell->next) in OS_CheckHeap()
1198 OSi_CHECK(InRange(cell, heapInfo->arenaStart, heapInfo->arenaEnd)); in OS_CheckHeap()
1199 OSi_CHECK(OFFSET(cell, ALIGNMENT) == 0); in OS_CheckHeap()
1200 OSi_CHECK(cell->next == NULL || cell->next->prev == cell); in OS_CheckHeap()
1201 OSi_CHECK(MINOBJSIZE <= cell->size); in OS_CheckHeap()
1202 OSi_CHECK(OFFSET(cell->size, ALIGNMENT) == 0); in OS_CheckHeap()
1203 OSi_CHECK(cell->next == NULL || (char *)cell + cell->size < (char *)cell->next); in OS_CheckHeap()
1205 total += cell->size; in OS_CheckHeap()
1206 free += cell->size - HEADERSIZE; in OS_CheckHeap()
1210 OSi_CHECK(cell->hd == NULL); in OS_CheckHeap()
1236 Cell *cell; in OS_ReferentSize() local
1250 cell = (Cell *) ((char *)ptr - HEADERSIZE); in OS_ReferentSize()
1252 SDK_ASSERTMSG(cell->hd, OS_ERR_REFERENT_INVPTR); in OS_ReferentSize()
1253 SDK_ASSERTMSG(((char *)cell->hd - (char *)heapInfo->heapArray) % sizeof(HeapDesc) == 0, in OS_ReferentSize()
1255 SDK_ASSERTMSG(heapInfo->heapArray <= cell->hd in OS_ReferentSize()
1256 && cell->hd < &heapInfo->heapArray[heapInfo->numHeaps], OS_ERR_REFERENT_INVPTR); in OS_ReferentSize()
1257 SDK_ASSERTMSG(0 <= cell->hd->size, OS_ERR_REFERENT_INVPTR); in OS_ReferentSize()
1258 SDK_ASSERTMSG(DLLookup(cell->hd->allocated, cell), OS_ERR_REFERENT_INVPTR); in OS_ReferentSize()
1261 return (u32)(cell->size - HEADERSIZE); in OS_ReferentSize()
1279 Cell *cell; in OS_DumpHeap() local
1322 for (cell = hd->allocated; cell; cell = cell->next) in OS_DumpHeap()
1325 cell, cell->size, (char *)cell + cell->size, cell->prev, cell->next); in OS_DumpHeap()
1336 for (cell = hd->free; cell; cell = cell->next) in OS_DumpHeap()
1339 cell, cell->size, (char *)cell + cell->size, cell->prev, cell->next); in OS_DumpHeap()
1367 Cell *cell; in OS_VisitAllocated() local
1380 for (cell = heapInfo->heapArray[heap].allocated; cell; cell = cell->next) in OS_VisitAllocated()
1382 visitor((void *)((u8 *)cell + HEADERSIZE), (u32)(cell->size - HEADERSIZE)); in OS_VisitAllocated()
1408 Cell *cell; in OSi_GetTotalAllocSize() local
1425 for (cell = heapInfo->heapArray[heap].allocated; cell; cell = cell->next) in OSi_GetTotalAllocSize()
1427 sum += (u32)(cell->size); in OSi_GetTotalAllocSize()
1432 for (cell = heapInfo->heapArray[heap].allocated; cell; cell = cell->next) in OSi_GetTotalAllocSize()
1434 sum += (u32)(cell->size - HEADERSIZE); in OSi_GetTotalAllocSize()
1457 Cell *cell; in OS_GetTotalFreeSize() local
1472 for (cell = heapInfo->heapArray[heap].free; cell; cell = cell->next) in OS_GetTotalFreeSize()
1474 sum += (u32)(cell->size - HEADERSIZE); in OS_GetTotalFreeSize()
1495 Cell *cell; in OS_GetMaxFreeSize() local
1510 for (cell = heapInfo->heapArray[heap].free; cell; cell = cell->next) in OS_GetMaxFreeSize()
1512 u32 size = (u32)(cell->size - HEADERSIZE); in OS_GetMaxFreeSize()
1541 Cell *cell; in OS_ClearHeap() local
1569 cell = (Cell *) start; in OS_ClearHeap()
1570 cell->prev = NULL; in OS_ClearHeap()
1571 cell->next = NULL; in OS_ClearHeap()
1572 cell->size = hd->size; in OS_ClearHeap()
1574 cell->hd = NULL; in OS_ClearHeap()
1577 hd->free = cell; in OS_ClearHeap()