};
/* Helper functions. */
-static char *mspan_allocate_from_superblock(char *base, mspan *superblock);
-static mspan *mspan_allocate_span_descriptor(char *base, mspan_manager *mgr);
static mspan_context *mspan_allocate_context_descriptor(char *base,
mspan_manager *mgr);
+static char *mspan_allocate_from_superblock(char *base, mspan *superblock);
+static mspan *mspan_allocate_span_descriptor(char *base, mspan_manager *mgr);
+static mspan *mspan_allocate_span(char *base, mspan_manager *mgr,
+ mspan_context *cxt, uint16 span_type, Size pages);
static void mspan_destroy_span(char *base, mspan *span);
static void mspan_ensure_active_superblock(char *base, mspan_context *cxt,
uint16 size_class);
Size pages = (size + MSPAN_PAGE_SIZE - 1) >> MSPAN_PAGE_BITS;
mspan *span;
- span = mspan_find_free_span(base, mgr, pages, 0);
- if (span != NULL)
- {
- /* XXX. Allocate the span, splitting it if required. */
- /*
- * XXX. Note that if we split a span than abutts the boundary,
- * we should instead destroy it and move back the boundary.
- */
- }
- else
+ span = mspan_allocate_span(base, mgr, cxt, MSPAN_TYPE_LARGE, pages);
+ if (span == NULL)
{
- /*
- * XXX. We need more core. Allocate either from the boundary or
- * via malloc.
- */
- /*
- * XXX. How exactly are we going to give the segments we malloc
- * back to the OS? How are we even going to know where they are?
- * We can add them to the freelists as a big old span, but that's
- * not going to help much in terms of identifying them later.
- */
+ if (base == NULL)
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
+ else
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of shared memory")));
}
}
if (span->npages > pages)
{
/* XXX. Split the span. */
+ /*
+ * XXX. Note that if we split a span than abutts the boundary,
+ * we should instead destroy it and move back the boundary.
+ */
}
}
- /* XXX. Allocate storage for a new span. */
+ /*
+ * XXX. We need more core. Allocate either from the boundary or
+ * via malloc.
+ */
+ /*
+ * XXX. How exactly are we going to give the segments we malloc
+ * back to the OS? How are we even going to know where they are?
+ * We can add them to the freelists as a big old span, but that's
+ * not going to help much in terms of identifying them later.
+ */
+
+ return NULL;
}
/*