return cxt;
}
+/*
+ * Attempt to allocate an object from a superblock.
+ */
+static char *
+mspan_allocate_from_superblock(char *base, mspan *superblock)
+{
+ /*
+ * XXX. Implementation needed.
+ */
+ return NULL;
+}
+
/*
* Allocate new space for a new span descriptor.
*/
}
}
- /*
- * XXX. We need to create a new span of spans, either from an available
- * span or by allocating from the boundary or OS.
- */
-}
-
-/*
- * Attempt to allocate an object from a superblock.
- */
-static char *
-mspan_allocate_from_superblock(char *base, mspan *superblock)
-{
- /*
- * XXX. Implementation needed.
- */
- return NULL;
+ /* Create a new span descriptor. */
+ span_of_spans =
+ mspan_allocate_span(base, mgr, NULL, MSPAN_TYPE_SPAN_OF_SPANS, 0);
+ if (span_of_spans == NULL)
+ return NULL;
+ return (mspan *) mspan_allocate_from_superblock(base, span_of_spans);
}
/*
}
}
+ /*
+ * If we're allocating a span of spans, the span descriptor will be
+ * carved out of the span itself; after all, it's intended to contain
+ * spans. Otherwise, we prefer to allocate the span descriptor here
+ * rather than after finding storage, because it's easier to back this
+ * out if storage allocation fails than the other way around.
+ */
+ if (span_type != MSPAN_TYPE_SPAN_OF_SPANS)
+ {
+ span = mspan_allocate_span_descriptor(base, mgr);
+ if (span == NULL)
+ return NULL;
+ }
+
/*
* XXX. We need more core. Allocate either from the boundary or
* via malloc.