Lines Matching defs:block

42  * Each page is divided in blocks. There is at least one block in a page.
59 struct block {
63 struct block *next;
70 struct block block[1];
76 #define HDR_BLOCK (sizeof (struct block) - sizeof (void *))
88 static void split(struct block *, size_t);
106 struct block *block;
118 for (block = page->block; block; block = block->next) {
119 if (block->status == FREE && block->size >= size)
140 block = page->block;
141 block->next = 0;
142 block->status = FREE;
143 block->size = totpage - HDR_PAGE;
144 block->page = page;
147 split(block, size);
149 block->status = BUSY;
150 return (&block->memstart);
156 struct block *block;
170 block = (struct block *)((char *)ptr - HDR_BLOCK);
172 osize = block->size;
175 * Join block with next one if it is free
177 if (block->next && block->next->status == FREE) {
178 block->size += block->next->size + HDR_BLOCK;
179 block->next = block->next->next;
182 if (size <= block->size) {
183 split(block, size);
190 block->status = FREE;
191 defrag(block->page);
199 struct block *block;
206 block = (struct block *)((char *)ptr - HDR_BLOCK);
207 block->status = FREE;
209 defrag(block->page);
226 split(struct block *block, size_t size)
228 if (block->size > size + sizeof (struct block)) {
229 struct block *newblock;
230 newblock = (struct block *)((char *)block + HDR_BLOCK + size);
231 newblock->next = block->next;
232 block->next = newblock;
234 newblock->page = block->page;
235 newblock->size = block->size - size - HDR_BLOCK;
236 block->size = size;
246 struct block *block;
248 for (block = page->block; block; block = block->next) {
249 struct block *block2;
251 if (block->status == BUSY)
253 for (block2 = block->next; block2 && block2->status == FREE;
255 block->next = block2->next;
256 block->size += block2->size + HDR_BLOCK;
263 if (page->block->size == page->size - HDR_PAGE) {