예제 #1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
DatabaseHandle::~DatabaseHandle()
{
	Check_Object(this);

	//
	//---------------------------------------------------------------
	// If we are closing a read only file, release the memmap handle,
	// otherwise delete the database object
	//---------------------------------------------------------------
	//
	if (m_readOnly)
		gos_CloseMemoryMappedFile(m_handle);
	else
	{
		Save();
		Check_Object(m_dataBase);

		//
		//---------------------------------------------------------------------
		// Now we need to go through and delete all the records in the database
		//---------------------------------------------------------------------
		//
		for (DWORD i=0; i<Database::e_DataBlockSize; ++i)
		{
			Record* record = reinterpret_cast<Record*>(m_dataBase->m_idOffsets[i]);
			if (record)
			{
				while (record)
				{
					record = reinterpret_cast<Record*>((DWORD)record + m_baseAddress);
					Check_Object(record);
					Record* this_record = record;

					record = reinterpret_cast<Record*>(record->m_nextIDRecord);
					if (this_record->m_mustFree)
						delete this_record;
				}
			}
		}

		//
		//--------------------------------
		// Now free up the database itself
		//--------------------------------
		//
		gos_Free(m_dataBase);
	}

	//
	//----------------------------------------------------
	// Delete the memory heap if this is the last database
	//----------------------------------------------------
	//
	if (--Database::FilesOpened == 0)
		gos_DestroyMemoryHeap(Database_Heap);
}
예제 #2
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	Plug::TerminateClass()
{
	Unregister_Object(DefaultData);
	delete DefaultData;
	DefaultData = NULL;

	Check_Pointer(ConnectionEngineHeap);
	gos_DestroyMemoryHeap(ConnectionEngineHeap);
	ConnectionEngineHeap = NULL;
}