// Create the VBs and stuff from our sys mem copies...
void CD3DVAMesh::ReCreateObject()
{
	// Create our VB...
	for (uint32 i=0;i<4;++i)
	{
		if (!m_VertStreamFlags[i])
			continue;
		if (!m_VBController.CreateStream(i,m_iVertCount,m_VertStreamFlags[i],eNO_WORLD_BLENDS,false,true,m_bSWVertProcessing))
		{
			FreeAll(); return;
		}
	}
	if (!m_VBController.CreateIndexBuffer(m_iPolyCount*3,false,true,m_bSWVertProcessing))
	{
		FreeAll();
		return;
	}

	// Read in our Verts...
	for (int i=0;i<4;++i)
	{
		if (!m_VertStreamFlags[i])
			continue;
		m_VBController.Lock((VertexBufferController::VB_TYPE)(VertexBufferController::eVERTSTREAM0 + i),false);
		uint8* pVertData = (uint8*)m_VBController.getVertexData(i);
		uint32 iSize = m_VBController.getVertexSize(i) * m_iVertCount;
		memcpy(pVertData,m_pVertData[i],iSize);
		m_VBController.UnLock((VertexBufferController::VB_TYPE)(VertexBufferController::eVERTSTREAM0 + i));
	}

	// Read in pIndexList...
	m_VBController.Lock(VertexBufferController::eINDEX,false);
	memcpy(m_VBController.getIndexData(),m_pIndexData,sizeof(uint16) * m_iPolyCount * 3);
	m_VBController.UnLock(VertexBufferController::eINDEX);
}
// Register Step Melody Notes into stepMelodyTestOut:
// Integrate the dynamic threshold adjustment here
void ArtStoryCore::StepToneRegistrationFromFreq(vector<float> abuffer){
	vector<int> astepToneMelody;
	vector<int> astepToneBass;
	vector<float>TestVisualInput(num_tones,0);
	int num_tones = 0;
	
	// the extracted tone indexes are from low to high
	for(unsigned int i = 0; i < abuffer.size(); i++){
		if(abuffer[i] == valueTop){
			int tonePoint = FreqToToneInd(i * FrequencyInterval);
			//push the tone into either bass or melody
			if(tonePoint < bassMelodyDevideTone){
				if(astepToneBass.size()<1){
					astepToneBass.push_back(tonePoint);
					num_tones++;
				}
				else if(tonePoint != astepToneBass.back()){
					astepToneBass.push_back(tonePoint);
					num_tones++;
				}
			}
			else{
				if(astepToneMelody.size()<1){
					astepToneMelody.push_back(tonePoint);
					num_tones++;
				}
				else if(tonePoint != astepToneMelody.back()){
					astepToneMelody.push_back(tonePoint);
					num_tones++;
				}
			}
		}
	}

	//perform dynamic threshold adjustment
	DynamicThresholdAdjustment(num_tones);
	
	//store the extracted tones
	stepMelody.push_back(astepToneMelody);

	// The following code is purely used to generate test
	// Ignore the lowest Base at Index 0
	//if(astepToneMelody.size()>0){
	//	for(unsigned int i = 0; i < astepToneMelody.size(); i++){
	//		int index = astepToneMelody[i];
	//		//Some Error Checking
	//		if(index >= 0){
	//			if(index >= TestVisualInput.size())
	//				index = TestVisualInput.size() - 1;

	//			TestVisualInput[index] = valueTop;	
	//		}
	//	}
	//}
	//
	//stepMelodyTestOut.push_back(TestVisualInput);

	FreeAll(TestVisualInput);
	FreeAll(astepToneMelody);
}
Esempio n. 3
0
//------------------------------------------------------
//	Empty Rhythmic Related States
//------------------------------------------------------
void RhythmicExtract::EmptyRhythmicStates(){
	initializedLevel = 0; //this is updated in the low pass filter
	
	FreeAll(SoundEnergy);
	FreeAll(lowPassedSoundEnergy);

	FreeAll(beatLevelDQue);

	FreeAll(beatStorageDQue);

	lowpassCounter = 0;
	
	maxLowPassedSoundEnergy = -10000; //assume the energy is never negative
	minLowPassedSoundEnergy = 9999999999999999999; //assume the energy is always smaller than this

	averageBeatLevel = 0;

	for(int i = 0; i < bufferNumberOfSecondLength; i++){
		averageLowPassedSound[i] = 0;
		varianceOfLowPassedSound[i] = 0;
		standardDeviationOfLowPassedSound[i] = 0;

		roughBeating[i] = false;
		fineBeating[i] = false;
		beatLastIter[i] = 0;
		currentBeatMagnitudeArray[i] = 0.0;
		dynamicThresholdScale[i] = beatThresholdStandardDeviationScale;
	}
}
Esempio n. 4
0
// Create the Sucka...
bool CD3D_Device::CreateDevice(D3DAdapterInfo* pAdapter,D3DDeviceInfo* pDevice,D3DModeInfo* pMode)
{
	if (!TdGuard::Aegis::GetSingleton().DoWork())
	{
		return false;
	}


	FreeDevice();								// Make sure it's all released and groovie...

	m_pAdapter	= pAdapter;						// Initialization...
	m_pDevice	= pDevice;
	m_pMode		= pMode;

	// Create the sucka...
	uint32 BehaviorFlags = D3DCREATE_MULTITHREADED;
	if (pDevice->d3dCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) 
	{
		BehaviorFlags |= D3DCREATE_MIXED_VERTEXPROCESSING;
	}
	else 
	{
		BehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
	}

	D3DPRESENT_PARAMETERS PresentationParam;
	SetPresentationParams(PresentationParam,pMode);
	HRESULT hResult = PDIRECT3D->CreateDevice(pAdapter->iAdapterNum,pDevice->DeviceType,g_hWnd_RenderWindow,BehaviorFlags,&PresentationParam,&m_pD3DDevice);
	if ((hResult != D3D_OK) || !m_pD3DDevice) 
	{	// Give it more more try - Presentation params might have been changed by D3D to something acceptable...
		OutputDebugString("Warning: Create failed. Attempting to fall back...\n");
		TryFallingBack_OnFailedDevCreate(&PresentationParam);

		hResult = PDIRECT3D->CreateDevice(pAdapter->iAdapterNum,pDevice->DeviceType,g_hWnd_RenderWindow,BehaviorFlags,&PresentationParam,&m_pD3DDevice);

		if ((hResult != D3D_OK) || !m_pD3DDevice) 
		{ 
			FreeAll(); 
			return false; 
		} 
	}

	if (FAILED(m_pD3DDevice->GetDeviceCaps(&m_DeviceCaps)))	
	{ 
		FreeAll(); 
		return false; 
	}

	SetDefaultRenderStates();					// Set the default render states...
	PreCalcSomeDeviceCaps();					// Do some precalcing of device caps (figure out if we can do some puff)...

	// Display a warning message
//	if (m_pDevice->DeviceType == D3DDEVTYPE_REF) AddDebugMessage(1,"Warning: Couldnt' find any HAL devices, Using reference rasterizer");

	return true;
}
Esempio n. 5
0
main() {
    int n;
    FreeAll();
    while(1) {
        n = Input();
        if(n == -1)	break;
        InsHash(n);
    }
    Find(),	FreeAll();
    return 0;
}
Esempio n. 6
0
int main(void)
    {
    int retval ;
    EXPR *expr ;

    ExprSetLineno(1) ;

    while( (retval = ExprLex(&expr)) != 0 )
	{
	if( retval == EXPR_TOKEN )
	    {
	    IOreport( "EXPR: " ) ;
	    ExprIOreport( expr ) ;
	    Free(expr) ;
	    IOreport( "\n" ) ;
	    }
	else
	if( retval == EXPR_ERTOK )
	    IOreport( "Syntax Error at line %d\n", ExprGetLineno() ) ;
	else
	    IOreport( "Character '%c'\n", retval ) ;
	}

    FreeAll() ;

    return 0 ;
    }
Esempio n. 7
0
void cRingStatusMenu::Exit()
{
    if(m_status_buff != NULL) {
        destroy_bitmap(m_status_buff);
        m_status_buff = NULL;
    }

    FreeAll();

    int i;
    for(i = 0; i < 2; ++i)
    {
        if(pstat[i].color_box != NULL) {
            destroy_bitmap(pstat[i].color_box);
        }

        if(pstat[i].player_type != NULL) {
            destroy_bitmap(pstat[i].player_type);
        }

        DELETE(pstat[i].name);
    }

    //
    DELETE(m_clock);
}
Esempio n. 8
0
void test::TestEntityPool() {
    auto entities = new stoked::EntityPool(4);

    auto e1 = entities->Create();
    auto e2 = entities->Create();
    auto e3 = entities->Create();
    auto e4 = entities->Create();

    assert(e1 != nullptr);
    assert(e2 != nullptr);
    assert(e3 != nullptr);
    assert(e4 != nullptr);

    assert(e1->GetID() < entities->GetCapacity());
    assert(e2->GetID() < entities->GetCapacity());
    assert(e3->GetID() < entities->GetCapacity());
    assert(e4->GetID() < entities->GetCapacity());

    assert(entities->Empty() && !entities->Available());

    entities->FreeAll();

    assert(!entities->Empty() && entities->Available());

    e1 = entities->Create();
    bool freeResult = entities->Free(e1);
    assert(freeResult == true);

    delete entities;

    PASSED();
}
Esempio n. 9
0
BOOL SERVER::SetMonitor (BOOL fShouldMonitor, ULONG *pStatus)
{
   BOOL rc = TRUE;
   ULONG status = 0;

   if (m_fMonitor != fShouldMonitor)
      {
      LPCELL lpCell;
      if ((lpCell = m_lpiCell->OpenCell (&status)) == NULL)
         rc = FALSE;
      else
         {
         NOTIFYCALLBACK::SendNotificationToAll (evtRefreshStatusBegin, GetIdentifier());

         if ((m_fMonitor = fShouldMonitor) == FALSE)
            {
            FreeAll();
            (lpCell->m_nServersUnmonitored)++;
            }
         else // (fMonitor == TRUE)
            {
            (lpCell->m_nServersUnmonitored)--;
            Invalidate();
            rc = RefreshAll (&status);
            }

         NOTIFYCALLBACK::SendNotificationToAll (evtRefreshStatusEnd, GetIdentifier(), m_lastStatus);
         lpCell->Close();
         }
      }

   if (!rc && pStatus)
      *pStatus = status;
   return rc;
}
Esempio n. 10
0
//---------------------------------------------------------------------------
__fastcall TTerminalManager::~TTerminalManager()
{
  FreeAll();

  assert(!ScpExplorer);

  assert(Configuration->OnChange == ConfigurationChange);
  Configuration->OnChange = NULL;

  assert(Application && (Application->OnException == ApplicationException));
  Application->OnException = NULL;
  assert(Application->OnShowHint == ApplicationShowHint);
  Application->OnShowHint = ApplicationShowHint;
  assert(Application->OnMessage == ApplicationMessage);
  Application->OnMessage = NULL;
  assert(Application->OnModalBegin == ApplicationModalBegin);
  Application->OnModalBegin = NULL;
  assert(Application->OnModalEnd == ApplicationModalEnd);
  Application->OnModalEnd = NULL;
  assert(WinConfiguration->OnMasterPasswordPrompt == MasterPasswordPrompt);
  WinConfiguration->OnMasterPasswordPrompt = NULL;

  delete FQueues;
  delete FTerminationMessages;
  delete FTerminalList;
  delete FAuthenticateForm;
  delete FQueueSection;
  ReleaseTaskbarList();
}
Esempio n. 11
0
 HRESULT v_ExecuteCommand()
 {
     ISearchManager *pSearchManager;
     HRESULT hr = CoCreateInstance(__uuidof(CSearchManager), NULL, CLSCTX_ALL, IID_PPV_ARGS(&pSearchManager));
     if (SUCCEEDED(hr))
     {
         ISearchCatalogManager *pCatalogManager;
         hr = pSearchManager->GetCatalog(L"SystemIndex", &pCatalogManager);
         if (SUCCEEDED(hr))
         {
             for (int i = 0; (i < m_cArgs) && SUCCEEDED(hr); i++)
             {
                 WCHAR szPattern[MAX_PATH];
                 // We are creating a pattern that looks like *.FILETYPE and reindexing urls that match this pattern.
                 hr = StringCchPrintf(szPattern, ARRAYSIZE(szPattern), L"*%s", szPattern);
                 if (SUCCEEDED(hr))
                 {
                     hr = pCatalogManager->ReindexMatchingURLs(szPattern);
                 }
             }
             pCatalogManager->Release();
         }
         pSearchManager->Release();
     }
     if (SUCCEEDED(hr))
     {
         Output(L"Succeeded!");
     }
     FreeAll();
     return S_OK;
 }
Esempio n. 12
0
BOOL CDownloadManager::Init(IContentManager* pContentManager, IPathManager* pPathManager)
{
	// Get rid of any old interfaces.
	FreeAll();

	// Attach the new content manager.
	if ((m_pContentManager = pContentManager) != NULL)
	{
		m_pContentManager->AddRef();
	}
	else
	{
		// NULL ContentManager passed to DownloadManager.
		ASSERT(FALSE);
		return FALSE;
	}

	// Attach the new path manager.
	if ((m_pPathManager = pPathManager) != NULL)
	{
		m_pPathManager->AddRef();
	}
	else
	{
		// NULL PathManager passed to DownloadManager.
		ASSERT(FALSE);
		return FALSE;
	}

	return TRUE;
}
Esempio n. 13
0
static void sig_handler(const int sig) 
{
    printf("SIGINT handled = %d.\n", sig);
    FreeAll();
    if (sig)
        exit(EXIT_SUCCESS);
}
Esempio n. 14
0
bool CD3DRigidMesh::Load(uint8* pSrcData)
{
	// Note: This is a renderobject file...
	LTB_Header Header; uint32 iSizeOf; uint32 iPieceType;
	memcpy(&Header,pSrcData,sizeof(Header));											pSrcData += sizeof(Header);
	memcpy(&iPieceType,pSrcData,sizeof(iPieceType));									pSrcData += sizeof(iPieceType);
	memcpy(&iSizeOf,pSrcData,sizeof(iSizeOf));											pSrcData += sizeof(iSizeOf);

	// Read in the basics...
	memcpy(&m_iVertCount,pSrcData,sizeof(m_iVertCount));								pSrcData += sizeof(m_iVertCount);
	memcpy(&m_iPolyCount,pSrcData,sizeof(m_iPolyCount));								pSrcData += sizeof(m_iPolyCount);
	memcpy(&m_iMaxBonesPerTri,pSrcData,sizeof(m_iMaxBonesPerTri));						pSrcData += sizeof(m_iMaxBonesPerTri);
	memcpy(&m_iMaxBonesPerVert,pSrcData,sizeof(m_iMaxBonesPerVert));					pSrcData += sizeof(m_iMaxBonesPerVert);
	memcpy(&m_VertStreamFlags[0],pSrcData,sizeof(uint32)*4);							pSrcData += sizeof(uint32)*4;
	memcpy(&m_iBoneEffector,pSrcData,sizeof(m_iBoneEffector));							pSrcData += sizeof(m_iBoneEffector);

	// Create our VB...
	for (uint32 i=0;i<4;++i) 
	{
		if (!m_VertStreamFlags[i]) continue;

		if (!m_VBController.CreateStream(i,m_iVertCount,m_VertStreamFlags[i],VertexBufferController::eNO_WORLD_BLENDS,false,true)) 
		{ 
			FreeAll(); 
			return false; 
		} 
	}

	if (!m_VBController.CreateIndexBuffer(m_iPolyCount*3)) { FreeAll(); return false; }

	// Read in our Verts...
	for (i=0;i<4;++i) 
	{
		if (!m_VertStreamFlags[i]) continue;
		m_VBController.Lock((VertexBufferController::VB_TYPE)(VertexBufferController::eVERTSTREAM0 + i),false); //true);
		uint8* pVertData = (uint8*)m_VBController.getVertexData(i);
		memcpy(pVertData,pSrcData,m_VBController.getVertexSize(i) * m_iVertCount);		pSrcData += m_VBController.getVertexSize(i) * m_iVertCount;
		m_VBController.UnLock((VertexBufferController::VB_TYPE)(VertexBufferController::eVERTSTREAM0 + i)); 
	}

	// Read in pIndexList...
	m_VBController.Lock(VertexBufferController::eINDEX, false); //true);
	memcpy(m_VBController.getIndexData(),pSrcData,sizeof(uint16) * m_iPolyCount * 3);	pSrcData += sizeof(uint16) * m_iPolyCount * 3;
	m_VBController.UnLock(VertexBufferController::eINDEX);

	return true; 
}
Esempio n. 15
0
void MelodyObj::NexAnimationObjGenerate(){
	if(!animationIndexAlreadyChose){
		NextAnmiationInfo();
	}

	//-----------------------------------------------------------------------
	//Calculate necessary condition and spawn the animation object
	//-----------------------------------------------------------------------
	bool spawndingConditionGood = false;
	if(effectiveMelodyLineToneList.size() > 1){
		spawndingConditionGood = BestMatchParameters(targetAnimationIndex);
	}

	if(spawndingConditionGood){
		memset(&theAniStruct, 0, sizeof(AStruct));

		theAniStruct.usingTex = true;

		theAniStruct.aControl = theControl;
		theAniStruct.vertex = 4;

		theAniStruct.theShape = rect_dia;

		theAniStruct.texInfo = theReader->GetTextureInfo(0, AnimationTexture);

		aniStructSpawnCondition =  RectDiaRadConstraintSpawning(x1, y1, x2, y2, 0, 0, previousAngleInRad, aniFlipped, theAniStruct);
		
		//simple entrance time setting
		theAniStruct.enterTime = (curTimeInMS - previousAnimationEndingTimeInMS)/1000;

		if(aniStructSpawnCondition){

			AObject * aAobject = new AObject(&theAniStruct);
			theChildren->Insert((AInterface*) aAobject);

			FreeAll(theAniStruct.aPositionQ);
			FreeAll(theAniStruct.aSpeedQ);

			inScreenTraceX.push_back(aAobject->GetAvgX());
			inScreenTraceY.push_back(aAobject->GetAvgY());

			aniFlipped = !aniFlipped;
			previousAnimationEndingTimeInMS = curTimeInMS;
		}
	}
}
Esempio n. 16
0
int MEPdfPartialB::FitParameters(RooDataSet *ds,const bool etaggflag){
  FreeAll();
  if(etaggflag) k_s_mbc_part->setConstant(kTRUE);
  pdf_part->fitTo(*ds,Verbose(),Timer(true));
  Draw(ds);
  PrintParameters();
  return 0;
}
Esempio n. 17
0
int CBoundaryTree::InsertRootNode( CPath& path )
{
	//empty the tree, then insert a new root node with path as boundary
	FreeAll();
	CBoundaryTreeNode root(path);
	root.nodeIdx = 0;
	rootIdx = data.Add(root);
	return(rootIdx);
}
void ArtStoryCore::StepFreRegistration(){
	int Bands = FrequencyBandSeparatorVec.size();
	vector<float> abuffer (melodyStoragesVecSize1, 0);

	//Sum the melodyStorage into Buffer
	for(unsigned int i = 0; i < melodyStoragesVecSize1; i++){
		for(unsigned int j = 0; j < melodyStoragesVecSize2; j++){
			if(j == 0)
				abuffer[i] = melodyStoragesVec[i][j];
			else
				abuffer[i] += melodyStoragesVec[i][j];
		}
	}
	
	
	// perform Banded Normalization
	for(int i = 0; i <= Bands; i++){
		int NextSeparatingIndex;
		int PreviousSeparatingIndex;
		float  BandMax;

		// find the starting and ending of each chunck;
		if(i == 0){
			NextSeparatingIndex = FrequencyBandSeparatorVec[i];
			PreviousSeparatingIndex = 0;		
		}else if(i == Bands){
			NextSeparatingIndex = abuffer.size();
			PreviousSeparatingIndex = FrequencyBandSeparatorVec[i-1];
		}else{
			NextSeparatingIndex = FrequencyBandSeparatorVec[i];
			PreviousSeparatingIndex = FrequencyBandSeparatorVec[i-1];
		}

		BandMax = abuffer[PreviousSeparatingIndex];

		//find the maximum
		for(int j = PreviousSeparatingIndex; j < NextSeparatingIndex; j++){
				if(BandMax < abuffer[j])
					BandMax = abuffer[j];
			}
		if(BandMax !=0){
			float factor = valueTop/BandMax;
			//normalize and hard decision
			for(int j = PreviousSeparatingIndex; j < NextSeparatingIndex; j++){
				abuffer[j] = abuffer[j] * factor;
			if(abuffer[j]>=dynamicThreshold)
				abuffer[j] = valueTop;
			else
				abuffer[j] = valueBottom;
			}
		}
	}//Bands

	StepToneRegistrationFromFreq(abuffer);
	FreeAll(abuffer);
}
Esempio n. 19
0
	// /////////////////////////////////////////////////////////////////
	//
	// /////////////////////////////////////////////////////////////////
	TextureManager::~TextureManager()
	{
		try
		{
			FreeAll();
		}
		catch(...)
		{
		}
	}
Esempio n. 20
0
void CStaticResourcePool::Cleanup()
{
	FreeAll();
	if (m_pItemPool)
	{
		ReleaseStaticMemoryPool(m_pItemPool);
	}
	ClearMember();

}
Esempio n. 21
0
double ProteinFDRestimator::estimateFDR(const std::set<std::string> &__target, const std::set<std::string> &__decoy)
{   
  
    time_t startTime;
    clock_t startClock;
    time(&startTime);
    startClock = clock();
    
    if(binnedProteins.size() > 0)
    {
       FreeAll(binnedProteins);
    } 
    if(binequalDeepth)
    {
      binProteinsEqualDeepth();
    }
    else
    {
      binProteinsEqualWidth();
    }
    
    if(VERB > 2)
    {
      std::cerr << "\nThere are : " << __target.size() << " target proteins and " << __decoy.size() 
      << " decoys proteins that contains high confident PSMs\n" << std::endl;    
    }

    double fptol = 0.0;
    for(unsigned i = 0; i < nbins; i++)
    {
      unsigned numberTP = countProteins(i,__target);
      unsigned numberFP = countProteins(i,__decoy);
      unsigned N = getBinProteins(i);
      double fp = estimatePi0HG(N,numberTP,static_cast<unsigned int>(targetDecoyRatio*numberFP));
      
      if(VERB > 2)
      {
	  std::cerr << "\nEstimating FDR for bin " << i << " with " << numberFP << " Decoy proteins, "
         << numberTP << " Target proteins, and " << N << " Total Proteins in the bin " << " with exp fp " << fp << std::endl;
      }

      fptol += fp;
    }
  
    time_t procStart;
    clock_t procStartClock = clock();
    time(&procStart);
    double diff = difftime(procStart, startTime);
    if (VERB > 2) std::cerr << "\nEstimating the protein FDR took : "
      << ((double)(procStartClock - startClock)) / (double)CLOCKS_PER_SEC
      << " cpu seconds or " << diff << " seconds wall time\n" << std::endl;
    
    if(std::isnan(fptol) || std::isinf(fptol) || fptol == 0)fptol = -1;
    return fptol ;
}
Esempio n. 22
0
// Create the Sucka...
bool CD3D_Shell::Create()
{
	if (!TdGuard::Aegis::GetSingleton().DoWork())
	{
		return false;
	}

	FreeAll();								// Make sure everything is all clean before we start...

	// Create the D3D Object (it lets us Query/Create devices)...
	m_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
	if (!m_pD3D) return false;

	// Get the Desktop display mode...
	if (FAILED(m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &m_DesktopFormat))) { FreeAll(); return false; }

	// Build the device lists (Adapters, Devices, Modes)...
	if (!BuildDeviceList())					{ FreeAll(); return false; }
	return true;
}
Esempio n. 23
0
void test::TestSpeed() {
    auto c1 = new stoked::ComponentPool<ComponentA>(1024);
    auto c2 = new stoked::ComponentPool<ComponentB>(1024);
    auto c3 = new stoked::ComponentPool<ComponentC>(1024);

    ComponentTypeValue c1ValueType = stoked::ComponentType::value<ComponentA>();
    ComponentTypeValue c2ValueType = stoked::ComponentType::value<ComponentB>();
    ComponentTypeValue c3ValueType = stoked::ComponentType::value<ComponentC>();

    assert(c1ValueType == stoked::ComponentType::value<ComponentA>());
    assert(c2ValueType == stoked::ComponentType::value<ComponentB>());
    assert(c3ValueType == stoked::ComponentType::value<ComponentC>());

    auto components = new stoked::ComponentPool<ComponentA>(1024);
    auto entities = new stoked::EntityPool(4096);

    auto start = std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1);

    unsigned int totalComponentsAdded = 0;
    const unsigned int ITERATIONS = 10000;
    for (int i = 0; i < ITERATIONS; ++i) {
        unsigned int j = 0;
        while (j < entities->GetEntities()->size()) {
            auto ent = entities->Create();
            assert(ent != nullptr);

            auto testComponent = components->Get();
            if (testComponent) {
                totalComponentsAdded++;
                ent->AddComponent(testComponent);

                assert(ent->ContainsComponent<ComponentA>());

                if (ent->ContainsComponent<ComponentA>()) {
                    auto com = ent->GetComponent<ComponentA>();
                    assert(com != nullptr);
                }
            }

            ++j;
        }
        entities->FreeAll();
    }

    auto end = std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1);

    fprintf(stderr, "Took %lu ms for %lu components\n", end - start, totalComponentsAdded);

    delete entities;
    delete components;

    PASSED();
}
Esempio n. 24
0
void CMemoryStack::Term()
{
	FreeAll();
	if ( m_pBase )
	{
#if defined(_WIN32)
		VirtualFree( m_pBase, 0, MEM_RELEASE );
#else
		MemAlloc_FreeAligned( m_pBase );
#endif
		m_pBase = NULL;
	}
}
//------------------------------------------------------
// Gussian Filtering Drive
//------------------------------------------------------
void ArtStoryCore::FilterDrive(){
	vector<vector<float>> atempMatrix(melodyStoragesVecSize1, vector<float>(melodyStoragesVec[0].size()));

	for(unsigned int i = 0; i < melodyStoragesVecSize1; i++){
		for(unsigned int j = 0; j < melodyStoragesVecSize2; j++){
				 atempMatrix[i][j] = FilteredEntry(i,j);
		}
	}

	FreeAll(atempMatrix);

	melodyStoragesVec = atempMatrix;
};
Esempio n. 26
0
int cControls::Exit()
{
   if(!m_exited)
   {
      remove_keyboard();
      remove_joystick();
      remove_mouse();

      FreeAll();

      m_exited = true;
   }

   return 0;
}
void FixedSizeAllocator::Reset(unsigned dataSize, unsigned pageSize, MemoryArena arena, unsigned alignment)
{
	FreeAll();

	// set memory arena type
	m_arena = arena;

	// order is important!
	//-----------------------------------
	m_dataSize = dataSize;
	m_pageSize = pageSize;
	m_alignmentSize = (MaxUINT(sizeof(BlockHeader), m_dataSize) % alignment) ? (alignment - MaxUINT(sizeof(BlockHeader), m_dataSize) % alignment) : (0);
	m_blockSize = MaxUINT(sizeof(BlockHeader), m_dataSize) + m_alignmentSize;
	m_blocksPerPage = (m_pageSize - sizeof(PageHeader)) / m_blockSize;
	//-----------------------------------
	// order is important!
}
Esempio n. 28
0
BOOL CLPRApp::InitInstance()
{
	// 如果一个运行在 Windows XP 上的应用程序清单指定要
	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
	//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// 将它设置为包括所有要在应用程序中使用的
	// 公共控件类。
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	AfxEnableControlContainer();

	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO: 应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));

	
	
	CLPRDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: 在此处放置处理何时用“确定”来关闭
		//  对话框的代码
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: 在此放置处理何时用“取消”来关闭
		//  对话框的代码
	}

	FreeAll();
	// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
	//  而不是启动应用程序的消息泵。
	return FALSE;
}
Esempio n. 29
0
SERVER::~SERVER (void)
{
   if (!m_fMonitor)
      {
      LPCELL lpCell;
      if ((lpCell = m_lpiCell->OpenCell()) != NULL)
         {
         (lpCell->m_nServersUnmonitored)--;
         lpCell->Close();
         }
      }

   if (m_lpiThis)
      m_lpiThis->m_cRef --;

   FreeAll();
   Delete (m_lAggregates);
   Delete (m_lServices);
}
Esempio n. 30
0
void ReadFile (struct nodo ** list)
{
	/* creates a new linked list from data in 'dlist.bin'
	deleting all repeated entries, filtering by nodo->nclient */
	struct nodo * aux = NULL;
	FILE	* fp;
	int	sizenodo = sizeof(struct nodo);
	/* first we make sure to free all the memory used by the list
	since we are going to create a new one */
	FreeAll (list);
	*list = NULL;
	if ((fp = fopen("dlist.bin", "rb")) == NULL)
	{
		ErrorOpeningFile();
		return;
	}
	/* we read the first record on the file and we add it to the
	beginning of the list */
	aux = (struct nodo *) malloc (sizenodo);
	fread(aux, sizenodo, 1, fp);
	AddBegin (list, aux);
	/* we do the loop while we are not in the end of file */
	while (!feof(fp))
	{
		aux = (struct nodo *) malloc (sizeof(struct nodo));
		if(fread(aux, sizenodo, 1, fp))
		{
			/* if nclient does not exist in our list then
			we add the node to the list */
			if (!NumberExists(list, aux->nclient))
				AddBetween(list, aux);
			else
				/* since I did not add the item to the list
				I free the memory used by it */
				free (aux);
		}
	}
	free (aux);
	printf("Data was read from \'dlist.bin\' and Double Linked List was created.\nPress any key to continue...");
	getch();
}