src/backend/utils/sort/logtape.c
/*
 * Select a currently unused block for writing to.
 *
 * NB: should only be called when writer is ready to write immediately,
 * to ensure that first write pass is sequential.
 */
Select a currently unused block for writing to.
NB: should only be called when writer is ready to write immediately,
to ensure that first write pass is sequential.
Select a currently unused block for writing to . NB : should only be called when writer is ready to write immediately to ensure that first write pass is sequential .
static long
ltsGetFreeBlock(LogicalTapeSet *lts)
{
	if (lts->nFreeBlocks > 0)
	{
		if (!lts->blocksSorted)
		{
			qsort((void *) lts->freeBlocks, lts->nFreeBlocks,
				  sizeof(long), freeBlocks_cmp);
			lts->blocksSorted = true;
		}
		return lts->freeBlocks[--lts->nFreeBlocks];
	}
	else
		return lts->nFileBlocks++;
}
static long ltsGetFreeBlock ( LogicalTapeSet * lts ) { if ( lts -> nFreeBlocks > 0 ) { if ( ! lts -> blocksSorted ) { qsort ( ( void * ) lts -> freeBlocks , lts -> nFreeBlocks , sizeof ( long ) , freeBlocks_cmp ) ; lts -> blocksSorted = true ; } return lts -> freeBlocks [ -- lts -> nFreeBlocks ] ; } else return lts -> nFileBlocks ++ ; }
Select a currently unused block for writing to.
Select a currently unused block for writing to .
/*
	 * If there are multiple free blocks, we select the one appearing last in
	 * freeBlocks[] (after sorting the array if needed).  If there are none,
	 * assign the next block at the end of the file.
	 */