Get back to where we can compile.
authorRobert Haas <rhaas@postgresql.org>
Thu, 16 Jan 2014 20:17:31 +0000 (15:17 -0500)
committerRobert Haas <rhaas@postgresql.org>
Thu, 6 Feb 2014 14:23:01 +0000 (09:23 -0500)
src/backend/utils/mmgr/mspan.c

index d08b4acc5a34e7319da35349c2df8a0cd8760cf2..67216f7a264482161c549ac1288e8141d31a509d 100644 (file)
@@ -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.