PassElement::~PassElement() { SAFE_DELETE(elemProgram); ClearVector( vecElemParam ); ClearVector( vecElemInput ); }
UINT BfTransfer::QryBfS(LPVOID pParam) { BfTransfer* pDlg = (BfTransfer*)pParam; CXTraderApp* pApp = (CXTraderApp*)AfxGetApp(); int nIndex = pDlg->m_cbBkLst.GetCurSel(); if (nIndex<0) { ShowErroTips(IDS_QRYBKERR,IDS_STRTIPS); return 0; } ClearVector(pApp->m_cT->m_BfTransVec); pApp->m_cT->ReqQryTfSerial(pApp->m_cT->m_AccRegVec[nIndex]->BankID); DWORD dwRet = WaitForSingleObject(g_hEvent,INFINITE); if (dwRet==WAIT_OBJECT_0) { ResetEvent(g_hEvent); } else { pDlg->m_pQryBf = NULL; return 0; } pDlg->m_pQryBf = NULL; return 0; }
void CSentencesCollection::ClearSentences() { for (int i = 0; i < m_vectorSents.size(); i++) delete m_vectorSents[i]; ClearVector(m_vectorSents); };
void ColladaObject::Clear() { SAFE_DELETE(elemCollada); SAFE_DELETE(elemAsset); SAFE_DELETE(elemScene); ClearVector( vecElemLibrary ); }
void CtpTraderSpi::ClrAllVecs() { ClearVector(m_orderVec); ClearVector(m_tradeVec); ClearVector(m_InsinfVec); ClearVector(m_StmiVec); ClearVector(m_AccRegVec); ClearVector(m_TdCodeVec); ClearVector(m_InvPosVec); ClearVector(m_BfTransVec); ZeroMemory(&m_RspMsg,sizeof(CThostFtdcRspInfoField)); }
void DebugFrontend::Shutdown() { m_state = State_Inactive; // Clean up the scripts. ClearVector(m_scripts); // Clean up. CloseHandle(m_process); m_process = NULL; m_processId = 0; }
void SymbolParser::OnSymbolsParsed(SymbolParserEvent& event) { if (m_project != NULL) { unsigned int fileId = event.GetFileId(); // Find the file that this corresponds to. It's possible that the file no longer // exists if some the project changed after the file was queued for parsing. Project::File* file = m_project->GetFileById(fileId); if (file != NULL) { ClearVector(file->symbols); file->symbols = event.GetSymbols(); // Pass along the event to the specified event handler. if (m_eventHandler != NULL) { m_eventHandler->AddPendingEvent(event); } return; } } // Need to delete the symbols or else we'll leak. const std::vector<Symbol*>& symbols = event.GetSymbols(); for (unsigned int i = 0; i < symbols.size(); ++i) { delete symbols[i]; } }
UINT DlgQryHiSet::QrySmi(LPVOID pParam) { QRYPARAM* pQryPara = static_cast<QRYPARAM*>(pParam); CXTraderApp* pApp = (CXTraderApp*)AfxGetApp(); ClearVector(pApp->m_cT->m_StmiVec); ((DlgQryHiSet*)pQryPara->pDlg)->m_szHiSet.Empty(); pApp->m_cT->ReqQrySettlementInfo(pQryPara->TdDay); DWORD dwRet = WaitForSingleObject(g_hEvent,INFINITE); if (dwRet==WAIT_OBJECT_0) { ResetEvent(g_hEvent); } else { ((DlgQryHiSet*)pQryPara->pDlg)->m_pQry = NULL; return 0; } ((DlgQryHiSet*)pQryPara->pDlg)->m_pQry = NULL; return 0; }
bool CSyntaxHolder::GetSentencesFromSynAn(string str, bool bFile) { clock_t t1,t2; int CountOfWords; try { m_Synan.ClearSentences(); ClearVector(m_PlmLines.m_Items); if (!GetMorphology(str, bFile, CountOfWords)) return false;; #ifdef _DEBUG m_PlmLines.SaveToFile("before.lem"); #endif // ============ Postmorphology ======================= CPlmLineCollection MapostPlmLines; if (m_bTimeStatis) t1= clock(); if (!m_pPostMorph->ProcessData(&m_PlmLines, MapostPlmLines)) { fprintf (stderr, " Cannot process Mapost\n"); return false; };; if (m_bTimeStatis) { t2 = clock(); double speed = ((double)CountOfWords)/((t2-t1)/((double)CLOCKS_PER_SEC)); fprintf(stderr,"Mapost: Ticks = %i Speed = %6.0f\n", t2-t1, speed ); }; #ifdef _DEBUG MapostPlmLines.SaveToFile("after.lem"); #endif // ============ Syntax ======================= if (m_bTimeStatis) t1= clock(); if (!m_Synan.ProcessData(&MapostPlmLines)) { fprintf (stderr, " Synan has crushed!\n"); return false; }; if (m_bTimeStatis) { t2 = clock(); double speed = ((double)CountOfWords)/((t2-t1)/((double)CLOCKS_PER_SEC)); fprintf(stderr,"Synan: Ticks = %i Speed = %6.0f\n", t2-t1, speed ); }; return true; } catch (...) { return false; }; }
wxThread::ExitCode SymbolParserThread::Entry() { while (!TestDestroy() && !m_exit) { // Wait for something to show up in the queue. m_itemsAvailable.Wait(); while (!TestDestroy()) { m_itemsLock.Enter(); if (m_items.empty()) { m_itemsLock.Leave(); break; } wxCriticalSectionLocker locker(m_headLock); m_headItem = m_items.back(); m_items.pop_back(); m_itemsLock.Leave(); if (m_eventHandler != NULL) { std::vector<Symbol*> symbols; wxStringInputStream input(m_headItem->code); ParseFileSymbols(input, symbols); m_itemsLock.Enter(); bool isLastItem=m_items.empty(); m_itemsLock.Leave(); // Dispatch the message to event handler. SymbolParserEvent event(m_headItem->fileId, symbols, isLastItem); m_eventHandler->AddPendingEvent(event); } delete m_headItem; m_headItem = NULL; } } wxCriticalSectionLocker locker1(m_itemsLock); ClearVector(m_items); wxCriticalSectionLocker locker2(m_headLock); delete m_headItem; m_headItem = NULL; return 0; }
GeometryElement::~GeometryElement() { SAFE_DELETE(elemMesh); ClearVector( vecElemExtra ); }
GameObject::~GameObject() { ClearVector(m_components); }
/* ----------------------------------------- main() ----------------------------------------- */ int main(void) { FILE* hFileInVectors; char text[MAX_CHARS] = {0}; int nQuit = FALSE; int nVector; int iResult; float fDistance; float fAngle; struct vector_t vectors[MAX_VECTORS]; WSADATA wsaData; struct addrinfo *result = NULL, *ptr = NULL, hints; SOCKET UdpSocket = INVALID_SOCKET; printf("BUILD: coordinates.c %s, %s\n", __DATE__, __TIME__); // -------------- CODE ----------- // open input file to get command vectors sprintf(text, "%s%s", FILE_DIR, INPUT_FILE); if ( (hFileInVectors = fopen(text,"r")) == NULL ) { ErrorExit("fopen() could not open vectors file."); } // initialize Winsock iResult = WSAStartup(MAKEWORD(2,2), &wsaData); if ( iResult != 0) { sprintf(text, "WSAStartup() failed with error: %d\n", iResult); fclose(hFileInVectors); ErrorExit(text); } ZeroMemory(&hints, sizeof (hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = IPPROTO_UDP; hints.ai_flags = AI_PASSIVE; // Resolve the local address and port to be used by the server iResult = getaddrinfo(DEFAULT_IP, DEFAULT_PORT, &hints, &result); if (iResult != 0) { sprintf(text, "getaddrinfo() failed with error: %d\n", iResult); fclose(hFileInVectors); WSACleanup(); ErrorExit(text); } // Create a SOCKET for the server UdpSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol); if (UdpSocket == INVALID_SOCKET) { sprintf(text, "socket() falied with error: %ld\n", WSAGetLastError()); fclose(hFileInVectors); freeaddrinfo(result); WSACleanup(); ErrorExit(text); } // Setup the TCP listening socket -- don't need to bind for UDP //iResult = bind( UdpSocket, result->ai_addr, (int) result->ai_addrlen); //if (iResult == SOCKET_ERROR) //{ // sprintf(text, "bind() failed with error: %d\n", WSAGetLastError()); // freeaddrinfo(result); // closesocket(UdpSocket); // WSACleanup(); // ErrorExit(text); //} ClearVector(&vectors[0]); printf(" [#] ( t , r ) tSum dX dY X Y | R t align\n"); printf(" ---- ----------- ---- --- --- --- --- | --- --- -----\n"); nVector = 1; while ( !feof(hFileInVectors) && !nQuit && nVector < MAX_VECTORS ) { text[0] = '\0'; fgets(text, MAX_CHARS, hFileInVectors); if ( text[0] != '#' ) { sscanf(text, "%g %g", &fAngle, &fDistance); CreateVector(fAngle, fDistance, &vectors[nVector], &vectors[nVector-1]); printf(" [%d] (%+.2f,%+.2f) %+.2f %+.2f %+.2f %+.2f %+.2f | %+.2f %+.2f %+.2f\n", nVector, fAngle, fDistance, vectors[nVector].fAngleSum, vectors[nVector].fDx, vectors[nVector].fDy, vectors[nVector].fX, vectors[nVector].fY, vectors[nVector].fOriginLength, vectors[nVector].fOriginAngle, vectors[nVector].fRealignAngle); GetHomeCommand(&vectors[nVector], &fAngle, &fDistance); printf(" get home: [%+.2f,%+.2f]\n", fAngle, fDistance); sprintf(text, "vector,%+.2f,%+.2f,%+.2f,%+.2f", vectors[nVector-1].fX, vectors[nVector-1].fY, vectors[nVector].fX, vectors[nVector].fY); // Echo the buffer to the client iResult = sendto(UdpSocket, text, strlen(text), 0, result->ai_addr, (int) result->ai_addrlen); if (iResult == SOCKET_ERROR) { sprintf(text, "sendto() failed with error: %d\n", WSAGetLastError()); fclose(hFileInVectors); closesocket(UdpSocket); WSACleanup(); ErrorExit(text); } sprintf(text, "obstacle,%+.2f,%+.2f", vectors[nVector].fX, vectors[nVector].fY); // Echo the buffer to the client iResult = sendto(UdpSocket, text, strlen(text), 0, result->ai_addr, (int) result->ai_addrlen); if (iResult == SOCKET_ERROR) { sprintf(text, "sendto() failed with error: %d\n", WSAGetLastError()); fclose(hFileInVectors); closesocket(UdpSocket); WSACleanup(); ErrorExit(text); } Sleep(500); nVector++; } } // vector position and error calculation // close all open handles fclose(hFileInVectors); freeaddrinfo(result); closesocket(UdpSocket); WSACleanup(); return 0; }
ExternalToolsDialog::~ExternalToolsDialog() { ClearVector(m_workingTools); }
FactionVector::FactionVector(int size) { vector = new Faction *[size]; vectorsize = size; ClearVector(); }
/********************************************************** Initialize **********************************************************/ #define PLOCK 0x400 static void feed(void) { PLLFEED = 0xAA; PLLFEED = 0x55; } #ifdef LPC214x void Initialize(void) { // Setting the Phased Lock Loop (PLL) // ---------------------------------- // // Olimex LPC-P2148 has a 12.0000 mhz crystal // // We'd like the LPC2148 to run at 60 mhz (has to be an even multiple of crystal) // // According to the Philips LPC2148 manual: M = cclk / Fosc where: M = PLL multiplier (bits 0-4 of PLLCFG) // cclk = 60000000 hz // Fosc = 12000000 hz // // Solving: M = 60000000 / 12000000 = 5 // // Note: M - 1 must be entered into bits 0-4 of PLLCFG (assign 4 to these bits) // // // The Current Controlled Oscilator (CCO) must operate in the range 156 mhz to 320 mhz // // According to the Philips LPC2148 manual: Fcco = cclk * 2 * P where: Fcco = CCO frequency // cclk = 60000000 hz // P = PLL divisor (bits 5-6 of PLLCFG) // // Solving: Fcco = 60000000 * 2 * P // P = 2 (trial value) // Fcco = 60000000 * 2 * 2 // Fcc0 = 240000000 hz (good choice for P since it's within the 156 mhz to 320 mhz range) // // From Table 22 (page 34) of Philips LPC2148 manual P = 2, PLLCFG bits 5-6 = 1 (assign 1 to these bits) // // Finally: PLLCFG = 0 01 00100 = 0x24 // // Final note: to load PLLCFG register, we must use the 0xAA followed 0x55 write sequence to the PLLFEED register // this is done in the short function feed() below // // Setting Multiplier and Divider values PLLCFG = 0x24; feed(); // Enabling the PLL */ PLLCON = 0x1; feed(); // Wait for the PLL to lock to set frequency while(!(PLLSTAT & PLOCK)) ; // Connect the PLL as the clock source PLLCON = 0x3; feed(); // Enabling MAM and setting number of clocks used for Flash memory fetch MAMTIM = 0x3; MAMCR = 0x2; // Setting peripheral Clock (pclk) to System Clock (cclk) VPBDIV = 0x1; } #else #define PLL_N 2UL #define PLL_M 72UL #define CCLK_DIV 4 #define USBCLKDivValue 5UL /* Fosc is divides by USBCLKDivValue+1 to make48MHz */ void Initialize(void) { #if 0 MEMMAP = 0x1; /* remap to internal flash */ PCONP |= 0x80000000; /* Turn On USB PCLK */ #endif // Setting the Phased Lock Loop (PLL) // ---------------------------------- // // CQ-FRK-NXP LPC2388 has a 12.0000 mhz crystal // // We'd like the LPC2388 to run at 72 mhz (has to be an even multiple of crystal) // // According to the Philips LPC2148 manual: M = cclk / Fosc where: M = PLL multiplier (bits 0-4 of PLLCFG) // cclk = 60000000 hz // Fosc = 12000000 hz // // Solving: M = 60000000 / 12000000 = 5 // // Note: M - 1 must be entered into bits 0-4 of PLLCFG (assign 4 to these bits) // // // The Current Controlled Oscilator (CCO) must operate in the range 156 mhz to 320 mhz // // According to the Philips LPC2148 manual: Fcco = cclk * 2 * P where: Fcco = CCO frequency // cclk = 60000000 hz // P = PLL divisor (bits 5-6 of PLLCFG) // // Solving: Fcco = 60000000 * 2 * P // P = 2 (trial value) // Fcco = 60000000 * 2 * 2 // Fcc0 = 240000000 hz (good choice for P since it's within the 156 mhz to 320 mhz range) // // From Table 22 (page 34) of Philips LPC2148 manual P = 2, PLLCFG bits 5-6 = 1 (assign 1 to these bits) // // Finally: PLLCFG = 0 01 00100 = 0x24 // // Final note: to load PLLCFG register, we must use the 0xAA followed 0x55 write sequence to the PLLFEED register // this is done in the short function feed() below // if ( PLLSTAT & (1 << 25) ) { PLLCON = 1; /* Disconnect PLL output if PLL is in use */ PLLFEED = 0xAA; PLLFEED = 0x55; } // Setting Multiplier and Divider values PLLCFG = ((PLL_N - 1) << 16) | (PLL_M - 1); /* Re-configure PLL */ feed(); // Enabling the PLL */ PLLCON = 0x1; feed(); // Wait for the PLL to lock to set frequency while ((PLLSTAT & (1 << 26)) == 0); /* Wait for PLL locked */ // while(!(PLLSTAT & PLOCK)) ; CCLKCFG = CCLK_DIV-1; /* Select CCLK frequency (divide ratio of hclk) */ USBCLKCFG = USBCLKDivValue; /* usbclk = 48 MHz */ // Connect the PLL as the clock source PLLCON = 0x3; feed(); MAMCR = 0; /* Configure MAM for 72MHz operation */ // Enabling MAM and setting number of clocks used for Flash memory fetch MAMTIM = 0x3; MAMCR = 0x2; PCLKSEL0 = 0x00000000; /* Select peripheral clock */ PCLKSEL1 = 0x00000000; ClearVector(); SCS |= 1; /* Enable FIO0 and FIO1 */ FIO1PIN2 = 0x04; /* -|-|-|-|-|LED|-|- */ FIO1DIR2 = 0x04; PINMODE3 = 0x00000020; #if 0 /* Initialize Timer0 as 1kHz interval timer */ RegisterVector(TIMER0_INT, Isr_TIMER0, PRI_LOWEST, CLASS_IRQ); T0CTCR = 0; T0MR0 = 18000 - 1; /* 18M / 1k = 18000 */ T0MCR = 0x3; /* Clear TC and Interrupt on MR0 match */ T0TCR = 1; IrqEnable(); #endif // uart0_init(INIT_BAUDRATE); // Setting peripheral Clock (pclk) to System Clock (cclk) }
/*! \brief Parse IPMP mutual authentication message. \warning Encoded data is modified during parsing. \warning In case of an error, throws either ByteSeqException or IPMPDataException. \param encoded input, encoded message. \returns IPMP mutual authentication message. */ MutualAuthenticationIPMPData* IPMPDataParser::ParseMutualAuthentication(ByteSeq& encoded) { // Get version. ByteT version = encoded.GetByte(); // Get data identifier. Bit32T dataID = encoded.GetBit32(); // Get flags. ByteT tmp = encoded.GetByte(); bool requestNegotiation = ((tmp & 0x80) == 0)? (false): (true); bool successNegotiation = ((tmp & 0x40) == 0)? (false): (true); bool failedNegotiation = ((tmp & 0x20) == 0)? (false): (true); bool inclAuthenticationData = ((tmp & 0x10) == 0)? (false): (true); bool inclAuthCodes = ((tmp & 0x08) == 0)? (false): (true); ByteSeq tmpArray; std::vector<AlgorithmDescriptor*> candidate; std::vector<AlgorithmDescriptor*> agreed; ByteSeq authenticationData; AuthCodes* codes = 0; try { if (requestNegotiation) { // Get number of candidate algorithms. tmp = encoded.GetByte(); while (tmp > 0) { // Get encoded algorithm descriptor data. if (encoded.GetByte() != 0x01) { throw IPMPDataParserException(); } tmpArray = encoded.GetBytes((UInt32T)(encoded.GetSizeOfInstance(0xfffffff))); candidate.push_back(ParseAlgorithmDescriptor(tmpArray)); tmp--; } } if (successNegotiation) { // Get number of agreed algorithms. tmp = encoded.GetByte(); while (tmp > 0) { // Get encoded algorithm descriptor data. if (encoded.GetByte() != 0x01) { throw IPMPDataParserException(); } tmpArray = encoded.GetBytes((UInt32T)(encoded.GetSizeOfInstance(0xfffffff))); agreed.push_back(ParseAlgorithmDescriptor(tmpArray)); tmp--; } } if (inclAuthenticationData) { authenticationData = encoded.GetBytes((UInt32T)(encoded.GetSizeOfInstance(0))); } if (inclAuthCodes) { tmp = encoded.GetByte(); if (tmp == 0x01) { // Parse certificates. ByteT nCert = encoded.GetByte(); ByteT certType = encoded.GetByte(); std::vector<ByteSeq> certs; while (nCert > 0) { certs.push_back(encoded.GetBytes((UInt32T)(encoded.GetSizeOfInstance(0)))); nCert--; } // Parse trust security metadata. if (encoded.GetByte() != 0x18) { throw IPMPDataParserException(); } tmpArray = encoded.GetBytes((UInt32T)(encoded.GetSizeOfInstance(0xfffffff))); TrustSecurityMetadataIPMPData* trustData = ParseTrustSecurityMetadata(tmpArray); tmpArray = encoded.GetBytes((UInt32T)(encoded.GetSizeOfInstance(0))); PublicAuthContext* context = new CertPublicAuthContext( std::vector<AlgorithmDescriptor*>(),trustData, certType, certs); codes = new AuthCodes(context, tmpArray); } else if (tmp == 0x02) { if (encoded.GetByte() != 0x02) { throw IPMPDataParserException(); } tmpArray = encoded.GetBytes((UInt32T)(encoded.GetSizeOfInstance(0xfffffff))); KeyDescriptor descriptor = ParseKeyDescriptor(tmpArray); // Parse trust security metadata. if (encoded.GetByte() != 0x18) { throw IPMPDataParserException(); } tmpArray = encoded.GetBytes((UInt32T)(encoded.GetSizeOfInstance(0xfffffff))); TrustSecurityMetadataIPMPData* trustData = ParseTrustSecurityMetadata(tmpArray); tmpArray = encoded.GetBytes((UInt32T)(encoded.GetSizeOfInstance(0))); PublicAuthContext* context = new KeyPublicAuthContext( std::vector<AlgorithmDescriptor*>(), trustData, descriptor); codes = new AuthCodes(context, tmpArray); } else if (tmp = 0xfe) { // Parse opaque. ByteSeq opaque = encoded.GetBytes((UInt32T)(encoded.GetSizeOfInstance(0))); // Parse trust security metadata. if (encoded.GetByte() != 0x18) { throw IPMPDataParserException(); } tmpArray = encoded.GetBytes((UInt32T)(encoded.GetSizeOfInstance(0xfffffff))); TrustSecurityMetadataIPMPData* trustData = ParseTrustSecurityMetadata(tmpArray); tmpArray = encoded.GetBytes((UInt32T)(encoded.GetSizeOfInstance(0))); PublicAuthContext* context = new OpaquePublicAuthContext( std::vector<AlgorithmDescriptor*>(), trustData, opaque); codes = new AuthCodes(context, tmpArray); } else { throw IPMPDataParserException(); } } } catch (ByteSeqException) { ClearVector(candidate); ClearVector(agreed); if (codes != 0) delete codes; throw ByteSeqException(); } catch (IPMPDataParserException) { ClearVector(candidate); ClearVector(agreed); if (codes != 0) delete codes; throw IPMPDataParserException(); } if (authenticationData.GetLength() > 0) { return new MutualAuthenticationIPMPData(version, dataID, failedNegotiation, candidate, agreed, authenticationData, codes); } else { return new MutualAuthenticationIPMPData(version, dataID, failedNegotiation, candidate, agreed, codes); } }
DebugFrontend::~DebugFrontend() { Stop(false); ClearVector(m_scripts); }
INT CSysParams::GetItemList(vector<LPITEMINFO>& vList) { ClearVector(&vList); INT nRet = ERR_UNKONW_ERROR; CMyDB db; if (!db.Connect()) return ERR_CANT_CONNECT_DB; USES_CONVERSION; // for W2A or A2W if (Lock(LOCK_WAIT_TIMEOUT)) { try { LPCTSTR pSQL = _T("SELECT ItemID, Address, DisplayName, NeedAccumulate, InConverter, OutConverter, DataType From MonitorItem WHERE Status='A'"); _RecordsetPtr pRS = db.GetRecordset(_variant_t(pSQL)); if (pRS) { DWORD dwBufLen; while (!pRS->adoEOF) { LPITEMINFO pItem = new ITEMINFO(); GetStringValue(pRS, 0, &(pItem->pItemID), dwBufLen); GetStringValue(pRS, 1, &(pItem->pAddress), dwBufLen); GetStringValue(pRS, 2, &(pItem->pDisplayName), dwBufLen); GetStringValue(pRS, 4, &(pItem->pInConverter), dwBufLen); GetStringValue(pRS, 5, &(pItem->pOutConverter), dwBufLen); _variant_t vRetVal = pRS->Fields->GetItem(_variant_t((long)6))->GetValue(); if (VT_I4 == vRetVal.vt) { pItem->vtRequestedDataType = vRetVal.lVal; } vRetVal = pRS->Fields->GetItem(_variant_t((long)3))->GetValue(); if (VT_BOOL == vRetVal.vt) { pItem->bNeedAccumulate = vRetVal.boolVal; } pItem->chStatus = _T('A'); vList.push_back(pItem); pRS->MoveNext(); } pRS->Close(); pRS.Release(); } else { nRet = db.GetLastErrorCode(); throw nRet; } } catch (...) { Unlock(); nRet; } Unlock(); nRet = vList.size(); } else { nRet = ERR_LOCK_TIMEOUT; } db.Disconnect(); return nRet; }
void KeyBinder::ClearCommands() { ClearVector(m_commands); }
void CNpcSpecialSkillCfg::UnLoadNpcSpecialSkill() { ClearVector(ms_vecNpcSpecialSkill); }
JointsElement::~JointsElement() { ClearVector(vecElemInput); }
OpticsElement::~OpticsElement() { ClearVector( vecElemProgram ); }