From: Robert Haas Date: Tue, 21 Jan 2014 14:13:16 +0000 (-0500) Subject: Hack. X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=b69b27237f25dca93c0160ef7bc4679b2568c206;p=users%2Frhaas%2Fpostgres.git Hack. --- diff --git a/src/backend/utils/mmgr/mspan.c b/src/backend/utils/mmgr/mspan.c index 372bd9f2e6..c0a81e5253 100644 --- a/src/backend/utils/mmgr/mspan.c +++ b/src/backend/utils/mmgr/mspan.c @@ -501,6 +501,33 @@ mspan_allocate_context_descriptor(char *base, mspan_manager *mgr) static char * mspan_allocate_from_superblock(char *base, mspan *superblock) { + char *spanbase; + uint16 object_size; + uint16 total; + + /* Quick exit if there are no free objects. */ + object_size = mspan_size_classes[superblock->span_type]; + total = MSPAN_SUPERBLOCK_SIZE / object_size; + if (superblock->nused >= total) + return NULL; + + /* Try to reuse a previously-freed object. */ + spanbase = base + superblock->first_page * MSPAN_PAGE_SIZE; + if (superblock->firstfree != MSPAN_FIRSTFREE_NONE) + { + uint16 *firstfree; + + firstfree = + (uint16 *) (spanbase + (superblock->firstfree * object_size)); + superblock->firstfree = *firstfree; + return (char *) firstfree; + } + + /* + * Carve out space from the uninitialized portion of the span. This + * should always work, since we already verified that nused < total. + */ + /* * XXX. Implementation needed. */