Lines Matching refs:cell

171 static Cell* DLAddFront(Cell* list, Cell* cell)  in DLAddFront()  argument
173 cell->next = list; in DLAddFront()
174 cell->prev = NULL; in DLAddFront()
176 list->prev = cell; in DLAddFront()
177 return cell; in DLAddFront()
190 static Cell* DLLookup(Cell* list, Cell* cell) in DLLookup() argument
194 if (list == cell) in DLLookup()
212 static Cell* DLExtract(Cell* list, Cell* cell) in DLExtract() argument
214 if (cell->next) in DLExtract()
215 cell->next->prev = cell->prev; in DLExtract()
216 if (cell->prev == NULL) in DLExtract()
217 return cell->next; in DLExtract()
220 cell->prev->next = cell->next; in DLExtract()
237 static Cell* DLInsert(Cell* list, Cell* cell) in DLInsert() argument
244 if (cell <= next) in DLInsert()
247 cell->next = next; in DLInsert()
248 cell->prev = prev; in DLInsert()
251 next->prev = cell; in DLInsert()
252 if ((char*) cell + cell->size == (char*) next) in DLInsert()
255 cell->size += next->size; in DLInsert()
256 cell->next = next = next->next; in DLInsert()
258 next->prev = cell; in DLInsert()
263 prev->next = cell; in DLInsert()
264 if ((char*) prev + prev->size == (char*) cell) in DLInsert()
267 prev->size += cell->size; in DLInsert()
276 return cell; // cell becomes new head of list in DLInsert()
294 Cell* cell; in DLOverlap() local
296 for (cell = list; cell; cell = cell->next) in DLOverlap()
298 if (RangeOverlap(cell, (char*) cell + cell->size, start, end)) in DLOverlap()
315 Cell* cell; in DLSize() local
318 for (cell = list; cell; cell = cell->next) in DLSize()
320 size += cell->size; in DLSize()
341 Cell* cell; // candidate block in OSAllocFromHeap() local
361 for (cell = hd->free; cell != NULL; cell = cell->next) in OSAllocFromHeap()
363 if ((long) size <= cell->size) in OSAllocFromHeap()
367 if (cell == NULL) in OSAllocFromHeap()
376 ASSERTMSG(OFFSET(cell, ALIGNMENT) == 0, OS_ERR_ALLOCFROMHEAP_BROKENHEAP); in OSAllocFromHeap()
377 ASSERTMSG(cell->hd == NULL, OS_ERR_ALLOCFROMHEAP_BROKENHEAP); in OSAllocFromHeap()
379 leftoverSize = cell->size - (long) size; in OSAllocFromHeap()
383 hd->free = DLExtract(hd->free, cell); in OSAllocFromHeap()
388 cell->size = (long) size; in OSAllocFromHeap()
391 newCell = (Cell*) ((char*) cell + size); in OSAllocFromHeap()
398 newCell->prev = cell->prev; in OSAllocFromHeap()
399 newCell->next = cell->next; in OSAllocFromHeap()
406 ASSERTMSG(hd->free == cell, OS_ERR_ALLOCFROMHEAP_BROKENHEAP); in OSAllocFromHeap()
412 hd->allocated = DLAddFront(hd->allocated, cell); in OSAllocFromHeap()
415 cell->hd = hd; in OSAllocFromHeap()
416 cell->requested = requested; in OSAllocFromHeap()
418 hd->paddingBytes += cell->size - (HEADERSIZE + requested); in OSAllocFromHeap()
422 return (void*) ((char*) cell + HEADERSIZE); in OSAllocFromHeap()
442 Cell* cell; // object iterator in OSAllocFixed() local
484 for (cell = hd->free; cell; cell = cell->next) in OSAllocFixed()
486 void* cellEnd = (char*) cell + cell->size; in OSAllocFixed()
490 if ((char*) end <= (char*) cell) in OSAllocFixed()
493 if (InRange(cell, (char*) start - HEADERSIZE, end) && in OSAllocFixed()
496 if ((char*) cell < (char*) start) in OSAllocFixed()
497 start = (void*) cell; in OSAllocFixed()
502 hd->free = DLExtract(hd->free, cell); // Note cell->next is intact. XXX in OSAllocFixed()
503 hd->size -= cell->size; // Update stats in OSAllocFixed()
507 if (InRange(cell, (char*) start - HEADERSIZE, end)) in OSAllocFixed()
509 if ((char*) cell < (char*) start) in OSAllocFixed()
510 start = (void*) cell; in OSAllocFixed()
521 newCell->next = cell->next; in OSAllocFixed()
524 newCell->prev = cell->prev; in OSAllocFixed()
529 hd->size -= (char*) end - (char*) cell; in OSAllocFixed()
540 ASSERT(MINOBJSIZE <= (char*) start - (char*) cell); in OSAllocFixed()
542 cell->size = (char*) start - (char*) cell; in OSAllocFixed()
553 newCell->next = cell->next; in OSAllocFixed()
556 newCell->prev = cell; in OSAllocFixed()
557 cell->next = newCell; // cell is before newCell in OSAllocFixed()
558 cell->size = (char*) start - (char*) cell; in OSAllocFixed()
587 Cell* cell; in OSFreeToHeap() local
595 cell = (Cell*) ((char*) ptr - HEADERSIZE); in OSFreeToHeap()
598 ASSERTMSG(cell->hd == hd, OS_ERR_FREETOHEAP_INVPTR); in OSFreeToHeap()
599 ASSERTMSG(DLLookup(hd->allocated, cell),OS_ERR_FREETOHEAP_INVPTR); in OSFreeToHeap()
602 cell->hd = NULL; in OSFreeToHeap()
604 hd->paddingBytes -= cell->size - (HEADERSIZE + cell->requested); in OSFreeToHeap()
605 hd->payloadBytes -= cell->requested; in OSFreeToHeap()
609 hd->allocated = DLExtract(hd->allocated, cell); in OSFreeToHeap()
612 hd->free = DLInsert(hd->free, cell); in OSFreeToHeap()
715 Cell* cell; in OSCreateHeap() local
749 cell = (Cell*) start; in OSCreateHeap()
750 cell->prev = NULL; in OSCreateHeap()
751 cell->next = NULL; in OSCreateHeap()
752 cell->size = hd->size; in OSCreateHeap()
754 cell->hd = NULL; in OSCreateHeap()
757 hd->free = cell; in OSCreateHeap()
837 Cell* cell; in OSAddToHeap() local
871 cell = (Cell*) start; in OSAddToHeap()
872 cell->size = (char*) end - (char*) start; in OSAddToHeap()
874 cell->hd = NULL; in OSAddToHeap()
878 hd->size += cell->size; in OSAddToHeap()
879 hd->free = DLInsert(hd->free, cell); in OSAddToHeap()
906 Cell* cell; in OSCheckHeap() local
917 for (cell = hd->allocated; cell; cell = cell->next) in OSCheckHeap()
919 CHECK(InRange(cell, ArenaStart, ArenaEnd)); in OSCheckHeap()
920 CHECK(OFFSET(cell, ALIGNMENT) == 0); in OSCheckHeap()
921 CHECK(cell->next == NULL || cell->next->prev == cell); in OSCheckHeap()
922 CHECK(MINOBJSIZE <= cell->size); in OSCheckHeap()
923 CHECK(OFFSET(cell->size, ALIGNMENT) == 0); in OSCheckHeap()
925 total += cell->size; in OSCheckHeap()
929 CHECK(cell->hd == hd); in OSCheckHeap()
930 CHECK(HEADERSIZE + cell->requested <= cell->size); in OSCheckHeap()
935 for (cell = hd->free; cell; cell = cell->next) in OSCheckHeap()
937 CHECK(InRange(cell, ArenaStart, ArenaEnd)); in OSCheckHeap()
938 CHECK(OFFSET(cell, ALIGNMENT) == 0); in OSCheckHeap()
939 CHECK(cell->next == NULL || cell->next->prev == cell); in OSCheckHeap()
940 CHECK(MINOBJSIZE <= cell->size); in OSCheckHeap()
941 CHECK(OFFSET(cell->size, ALIGNMENT) == 0); in OSCheckHeap()
942 CHECK(cell->next == NULL || (char*) cell + cell->size < (char*) cell->next); in OSCheckHeap()
944 total += cell->size; in OSCheckHeap()
945 free += cell->size - HEADERSIZE; in OSCheckHeap()
949 CHECK(cell->hd == NULL); in OSCheckHeap()
970 Cell* cell; in OSReferentSize() local
977 cell = (Cell*) ((char*) ptr - HEADERSIZE); in OSReferentSize()
979 ASSERTMSG(cell->hd, OS_ERR_REFERENT_INVPTR); in OSReferentSize()
980 ASSERTMSG(((char*) cell->hd - (char*) HeapArray) % sizeof(HeapDesc) == 0, in OSReferentSize()
982 ASSERTMSG(HeapArray <= cell->hd && cell->hd < &HeapArray[NumHeaps], in OSReferentSize()
984 ASSERTMSG(0 <= cell->hd->size, OS_ERR_REFERENT_INVPTR); in OSReferentSize()
985 ASSERTMSG(DLLookup(cell->hd->allocated, cell), in OSReferentSize()
988 return (u32) (cell->size - HEADERSIZE); in OSReferentSize()
1003 Cell* cell; in OSDumpHeap() local
1031 for (cell = hd->allocated; cell; cell = cell->next) in OSDumpHeap()
1034 cell, in OSDumpHeap()
1035 cell->size, in OSDumpHeap()
1036 (char*) cell + cell->size, in OSDumpHeap()
1037 cell->prev, in OSDumpHeap()
1038 cell->next in OSDumpHeap()
1043 for (cell = hd->free; cell; cell = cell->next) in OSDumpHeap()
1046 cell, in OSDumpHeap()
1047 cell->size, in OSDumpHeap()
1048 (char*) cell + cell->size, in OSDumpHeap()
1049 cell->prev, in OSDumpHeap()
1050 cell->next in OSDumpHeap()
1069 Cell* cell; in OSVisitAllocated() local
1075 for (cell = HeapArray[heap].allocated; cell; cell = cell->next) in OSVisitAllocated()
1077 visitor((void*)((u8*)cell + HEADERSIZE), (u32)cell->size); in OSVisitAllocated()