/* If it's bigger than the largest size class, allocate whole pages. */
if (size > mspan_size_classes[lengthof(mspan_size_classes) - 1])
{
+ mspan_manager *mgr = relptr_access(base, cxt->manager);
Size pages = (size + MSPAN_PAGE_SIZE - 1) >> MSPAN_PAGE_BITS;
mspan *span;
uint16 min = mspan_size_class_map[lengthof(mspan_size_class_map) - 1];
uint16 max = lengthof(mspan_size_classes) - 1;
- for (;;)
+ while (min < max)
{
uint16 mid = (min + max) / 2;
+ uint16 class_size = mspan_size_classes[mid];
- /* XXX bsearch */
+ if (class_size < size)
+ min = mid + 1;
+ else
+ max = mid;
}
+
+ size_class = min;
}
+ Assert(size <= mspan_size_classes[size_class]);
+
+ /*
+ * XXX Search existing superblocks for a chunk of memory.
+ */
- /* XXX Search superblocks, etc. */
+ /*
+ * XXX If we couldn't find memory in an existing superblock, allocate
+ * a new superblock for the appropriate size class.
+ */
}
/*
/*
* XXX. As a special case, the superblock descriptor for a span of
* spans is always stored within the span itself. Return the span
- * to be destroyed to the superblock, and then, there's only 1 remaining
+ * to be destroyed to the superblock, and then, if there's only 1 remaining
* span outstanding, nuke the whole superblock.
*/
}