From e3cb32796bf240d9aef0dd1b1f7c19682cccd714 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Thu, 16 Jan 2014 15:17:31 -0500 Subject: [PATCH] Get back to where we can compile. --- src/backend/utils/mmgr/mspan.c | 48 ++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/backend/utils/mmgr/mspan.c b/src/backend/utils/mmgr/mspan.c index d08b4acc5a..67216f7a26 100644 --- a/src/backend/utils/mmgr/mspan.c +++ b/src/backend/utils/mmgr/mspan.c @@ -493,6 +493,18 @@ mspan_allocate_context_descriptor(char *base, mspan_manager *mgr) 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. */ @@ -535,22 +547,12 @@ mspan_allocate_span_descriptor(char *base, mspan_manager *mgr) } } - /* - * 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); } /* @@ -616,6 +618,20 @@ mspan_allocate_span(char *base, mspan_manager *mgr, mspan_context *cxt, } } + /* + * 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. -- 2.39.5