void CTLSStorageArray::FreeInstance(tlsindextype iValueCount)
{
	if (GetIsAnyBlockOccupied())
	{
		FreeStorageAllBlocks(iValueCount);
	}

	this->CTLSStorageArray::~CTLSStorageArray();
	FreeMemoryBlock((void *)this);
}
示例#2
0
const int MemBlockDevice::SaveFile(const std::string & data, FileHeader& file, int blocknr)
{
	for (int i = 0; i < file.nrofblocks; i++)
	{
		FreeMemoryBlock(file.blockPointers[i]);
	}
	if (file.nrofblocks > 0)
		file.blockPointers = 0;

	file.size = data.size();
	file.nrofblocks = (file.size / blocksize) + ((file.size % blocksize) ? 1 : 0);
	if(file.nrofblocks > 0)
		file.blockPointers = new int[file.nrofblocks];



	for (int i = 0; i < file.nrofblocks; i++)
	{
		file.blockPointers[i] = GetNextFreeBlock();
		if (file.blockPointers[i] == -1)
		{
			return -1;
		}
	}
	int err = writeBlock(blocknr, (char*)&file, sizeof(int)*4, 0 );
	if (err != 1)
	{
		return -1;
	}
	
	err = writeBlock(blocknr, file.name.c_str(), file.namesize, sizeof(int) * 4);
	if (err != 1)
	{
		return -1;
	}
	err = writeBlock(blocknr, (char*)file.blockPointers, sizeof(int)*file.nrofblocks, sizeof(int) * 4 + file.namesize);
	if (err != 1)
	{
		return -1;
	}
	int size = file.size;
	for (int i = 0; i < file.nrofblocks; i++)
	{
		int s = (size < blocksize) ? size%blocksize : blocksize;
		int err = writeBlock(file.blockPointers[i], (data.c_str() + i*blocksize), s, 0);
		if (err != 1)
		{
			return -1;
		}
		size -= blocksize;
	}

	return 1;
}
示例#3
0
static BOOL HandleSubstitution()
{
BOOL done = FALSE;
int LineNo = 0;
char *FixedLine;
BOOL HadChanges = FALSE;

/* now process the file */
while ( !done )
	{
	if ( ReadLine( ) != 0 )
		done = TRUE;
	else
		{
		++LineNo;
		/*
		TracePrintf( "HandleSubstitution: Processing Line %d\n", LineNo );
		*/
		FixedLine = XTL_Substitute( LineBuffer );
		
		if ( FixedLine == NULL )  /* Bad things happened */
			ErrorExit( "HandleSubstitution() Line blew up" );
		
		if ( ! HadChanges )
		{
			if ( strcmp( FixedLine, LineBuffer ) != 0 )
				HadChanges = TRUE;
		}
	
		WriteToOutputBuffer( FixedLine, strlen(FixedLine) );		
		FreeMemoryBlock( FixedLine );
		}
	}

	
printf( "HandleSubstitution: Processed %d lines for substitution processing this pass\n", LineNo );

return HadChanges;

}
void CTLSStorageInstance::FreeInstance()
{
	this->CTLSStorageInstance::~CTLSStorageInstance();
	FreeMemoryBlock(this);
}