* bt_freehead_toalloc: return the freelist for the given size and allocation * strategy. * * For M_FIRSTFIT, return the list in which any blocks are large enough * for the requested size. otherwise, return the list which can have blocks * large enough for the requested size. */
| 421 | * large enough for the requested size. |
| 422 | */ |
| 423 | static struct vmem_freelist * |
| 424 | bt_freehead_toalloc(vmem_t *vm, vmem_size_t size, int strat) |
| 425 | { |
| 426 | const vmem_size_t qsize = size >> vm->vm_quantum_shift; |
| 427 | int idx = SIZE2ORDER(qsize); |
| 428 | |
| 429 | MPASS(size != 0 && qsize != 0); |
| 430 | MPASS((size & vm->vm_quantum_mask) == 0); |
| 431 | |
| 432 | if (strat == M_FIRSTFIT && ORDER2SIZE(idx) != qsize) { |
| 433 | idx++; |
| 434 | /* check too large request? */ |
| 435 | } |
| 436 | MPASS(idx >= 0); |
| 437 | MPASS(idx < VMEM_MAXORDER); |
| 438 | |
| 439 | return &vm->vm_freelist[idx]; |
| 440 | } |
| 441 | |
| 442 | /* ---- boundary tag hash */ |
| 443 |