예제 #1
0
void
HDBNode::removeBlock(HDBHandle& hdl, HDBBlock& fblk, Int32 offset)
{
	AutoPtrVec<unsigned char>
		pbfr(new unsigned char[LMAX(sizeof(fblk), fblk.keyLength)]);
	File file = hdl.getFile();
	Int32 coffset = fblk.lastChild;
	if (coffset > 0)
	{
		while (coffset > 0)
		{
			HDB::readBlock(*(reinterpret_cast<HDBBlock*>(pbfr.get())), file, coffset);
			// Save current offset for call to removeBlock
			Int32 toffset = coffset;
			// Get pointer to previous sibling
			coffset = (reinterpret_cast<HDBBlock*>(pbfr.get()))->prevSib;
			// Recursive call to removeBlock. *pblk.get() will be modified.
			removeBlock(hdl, *(reinterpret_cast<HDBBlock*>(pbfr.get())), toffset);
		}
	}
	// Need to read the key for this block to update the index
	if (file.read(pbfr.get(), fblk.keyLength, offset + sizeof(fblk))
		!= size_t(fblk.keyLength))
	{
		OW_THROW_ERRNO_MSG(HDBException, "Failed to read node's key for removal");
	}
	// Remove this node's key from the index
	hdl.removeIndexEntry(reinterpret_cast<const char*>(pbfr.get()));
	// Add the block to the free list
	hdl.getHDB()->addBlockToFreeList(file, fblk, offset);
}
예제 #2
0
파일: key.c 프로젝트: d2emon/abermud
key_reprint()
{
	extern long pr_due;
	extern long pr_qcr;
	pr_qcr=1;
	pbfr();
	if((key_mode==0)&&(pr_due))
		printf("\n%s%s",pr_bf,key_buff);
	pr_due=0;
	fflush(stdout);
}