void P2PProxySession::OnMessage(talk_base::Message *msg){ ASSERT(signal_thread_->IsCurrent()); switch(msg->message_id){ case DESTORY_SELFT: { if(p2p_connection_implementator_ != NULL){ std::cout << "delete p2p connection implementation" << std::endl; delete p2p_connection_implementator_; p2p_connection_implementator_ = NULL; } if(p2p_proxy_sockets_.size() == 0){ std::cout << "delete proxy p2p session" << std::endl; p2p_connection_management_->DeleteP2PProxySession(this); } break; } case CLOSE_ALL_PROXY_SOCKET: { break; } case SEND_BUFFER_DATA: { LOG_P2P(P2P_PROXY_SOCKET_LOGIC) << "Send command data"; if(state_ == P2P_CLOSE) return ; //send this string to remote peer size_t written; /////////////////////////////////////////////////////////////////// //when p2p connection implementation is NULL, is can't send message //it is normal but it very important /////////////////////////////////////////////////////////////////// if(p2p_connection_implementator_ == NULL || command_data_buffers_.empty()){ return ; } P2PCommandData *p2p_command_data = command_data_buffers_.front(); p2p_connection_implementator_->Send(0,TCP_SOCKET, p2p_command_data->data_,p2p_command_data->len_,&written); if(written == P2PRTSPCOMMAND_LENGTH){ command_data_buffers_.pop(); delete p2p_command_data; } break; } case RELEASE_ALL: { if(p2p_proxy_sockets_.size() == 0) Destory(); break; } case DELAYED_CLOSE: { if(state_ == P2P_CLOSING){ state_ = P2P_CLOSE; Destory(); } } } }
void RedBlackTree::Destory(TreeNode *T) { if (T != m_pSentinel && T != NULL ) { Destory(T->left) ; Destory(T->right) ; } }
void Destory(HuffmanNode_P<T>*& root) { if (root) { Destory(root->_left); Destory(root->_right); delete root; root = NULL; } }
Status Destory(TREE_TYPE* tree) { if (*tree == NULL) return OK; Destory(&((*tree) -> first_child)); Destory(&((*tree) -> next_sibling)); free(*tree); *tree = NULL; return OK; }
bool CGameSocket::SendMsg(BYTE* pBuf, int nSize) { if (pBuf == NULL || nSize <= 0) return false; if (m_sockClient == INVALID_SOCKET) return false; // 检查消息包长度 int nPackSize = 0; nPackSize = nSize; // 检测BUFFER溢出 if (m_nOutBufLen + nSize > OUTBUFSIZE) { // 立即发送OUTBUF中的数据,以清空OUTBUF Flush(); if (m_nOutBufLen + nSize > OUTBUFSIZE) { // 出错了 Destory(); return false; } } // 数据添加到BUF尾 memcpy(m_outBuf + m_nOutBufLen, pBuf, nSize); m_nOutBufLen += nSize; Flush(); return true; }
BOOL CThreadSafeCycleBufferEx::Create(LPVOID pBuff,UINT Size,UINT SmoothSize) { Destory(); CAutoLockEx FrontLock; if(m_IsLockFront) { FrontLock.Lock(m_FrontLock); } CAutoLockEx BackLock; if(m_IsLockBack) { BackLock.Lock(m_BackLock); } if(Size<=SmoothSize*2) { return FALSE; } m_pBuffer=(BYTE *)pBuff; m_BufferSize=Size-SmoothSize; m_SmoothSize=SmoothSize; m_BufferHead=0; m_BufferTail=0; m_IsSelfBuffer=false; return TRUE; }
BOOL CNetPTCPConnection::Create(UINT RecvQueueSize,UINT SendQueueSize) { if(GetServer()==NULL) return FALSE; Destory(); if(m_pEpollEventRouter==NULL) { m_pEpollEventRouter=GetServer()->CreateEventRouter(); m_pEpollEventRouter->Init(this); } m_Socket.MakeSocket(AF_INET,SOCK_STREAM,IPPROTO_TCP); if(m_SendQueue.GetBufferSize()<SendQueueSize) { m_SendQueue.Create(SendQueueSize); } else { m_SendQueue.Clear(); } return TRUE; }
BOOL CNetPTCPConnection::Create(SOCKET Socket,UINT RecvQueueSize,UINT SendQueueSize) { if(GetServer()==NULL) return FALSE; Destory(); if(m_pEpollEventRouter==NULL) { m_pEpollEventRouter=GetServer()->CreateEventRouter(); m_pEpollEventRouter->Init(this); } m_Socket.SetSocket(Socket); if(m_SendQueue.GetBufferSize()<SendQueueSize) { m_SendQueue.Create(SendQueueSize); } else { m_SendQueue.Clear(); } return TRUE; }
AudioInputEngine::~AudioInputEngine(void) { if (bInit) { Destory(); } }
void P2PProxySession::IsAllProxySocketClosed(){ ASSERT(signal_thread_->IsCurrent()); if(p2p_proxy_sockets_.size() == 0){ /////////////////////////////////////////////////////////////////////////// //BUSINESS LOGIC NOTE (GuangleiHe, 12/5/2013) //Because to close a stream (a ICE p2p connection), the ice protect has it //own method to close this, if you close this stream before the ice close // there will getting the bug. /////////////////////////////////////////////////////////////////////////// //if(is_self_close) // p2p_connection_implementator_->CloseStream(); if(state_ == P2P_CONNECTED){ state_ = P2P_CLOSING; } else { state_ = P2P_CLOSE; Destory(); } if(session_type_ == RTSP_SERVER){ signal_thread_->PostDelayed(DELAYED_CLOSE_WAIT_TIME, this,DELAYED_CLOSE); std::cout << "will destroy this session after " << DELAYED_CLOSE_WAIT_TIME/1000 << "s" << std::endl; } else if(session_type_ == HTTP_SERVER){ signal_thread_->PostDelayed(DELAYED_CLOSE_WAIT_TIME * 10, this,DELAYED_CLOSE); std::cout << "will destroy this session after " << DELAYED_CLOSE_WAIT_TIME/100 << "s" <<std::endl; } //signal_thread_->PostDelayed(1000 * 60,this,RELEASE_ALL); } }
CDBTransationWorkThread::~CDBTransationWorkThread(void) { SS_TRY_BEGIN; Destory(); SS_TRY_END(); }
bool CGameSocket::Flush() { if (m_sockClient == INVALID_SOCKET) return false; if (m_nOutBufLen <= 0) return true; int nOutSize = send(m_sockClient, m_outBuf, m_nOutBufLen, 0); //CCLOG("send size: %d", nOutSize); if (nOutSize > 0) { if (m_nOutBufLen - nOutSize > 0) { memcpy(m_outBuf, m_outBuf + nOutSize, m_nOutBufLen - nOutSize); } m_nOutBufLen -= nOutSize; assert(m_nOutBufLen >= 0); return Flush(); } else { if (hasError()) { Destory(); return false; } return true; } }
inline void __DestoryAux(ForwardIterator first, ForwardIterator last, __FalseType) { while (first < last) { Destory(&(*first)); first++; } }
void ConformalResizing::ConstrainUnits::SetNumber(int _n) { Destory(); n = _n; CmAssert(n != 0); pnts = new CvPoint2D64f[n]; ind = new int[n]; }
Status DeleteChild(TREE_TYPE tree, TREE_NODE* node, int position) { if (position == 1) { Destory(&(node -> first_child)); } else { int order = 1; TREE_NODE *child = node -> first_child; while (order < position - 1) { child = child -> next_sibling; order++; } TREE_NODE *n = child -> next_sibling; child -> next_sibling = child -> next_sibling -> next_sibling; n -> next_sibling = NULL; Destory(&n); } return OK; }
int main(int argc, char *argv[]) { ST my_st; my_st = Init_ST(); Create(my_st , "info_file"); Traverse(my_st); printf("Find the 14 index is %d\n",Search(my_st , 56)); Destory(my_st); }
void test_Destory(void) { BINARY_TREE_TYPE tree = get_test_tree("1,2,3,4,5"); if (tree == NULL) return; Status status = Destory(&tree); CU_ASSERT_EQUAL(status, OK); CU_ASSERT_PTR_NULL(tree); }
/** * Build topology of triangle mesh * * @param trimesh: input triangle mesh * @param fBuildVert: true indicate build vert_topo, or skip vert_topo * @return true: success * false: failed */ bool niTriMesh2dTopo::BuildTopology(const niTriMesh2d& trimesh, bool fBuildVert) { Destory(); bool bStat; if (!trimesh.IsValid()) return false; int num_verts = trimesh.NumPoints(); int num_faces = trimesh.NumFaces(); try { m_v2ef_list.resize(num_verts); m_f2ve_list.resize(num_faces); } catch (std::bad_alloc) { Destory(); return false; } bStat = BuildEdge2VF(trimesh); if (!bStat) return bStat; bStat = BuildFace2VE(trimesh); if (!bStat) return bStat; if (fBuildVert) { bStat = BuildVert2EF(trimesh); if (!bStat) return bStat; } if (fBuildVert) m_valid = true; return true; }
void test_Destory(void) { Status status = ERROR; GENERALIZED_LIST_TYPE list = getGeneralizedList("(1,2,3,4)"); if (list == NULL) return; status = Destory(&list); CU_ASSERT_EQUAL(status, OK); CU_ASSERT_PTR_NULL(list); }
void GameEngine::Run() { if (!mInitialized) { Initialize(); } Loop(); Destory(); }
void CDBValue::operator=(const CEasyTime& Value) { Destory(); DB_TIMESTAMP DBValue; DBValue.year=((CEasyTime)Value).Year(); DBValue.month=((CEasyTime)Value).Month(); DBValue.day=((CEasyTime)Value).Day(); DBValue.hour=((CEasyTime)Value).Hour(); DBValue.minute=((CEasyTime)Value).Minute(); DBValue.second=((CEasyTime)Value).Second(); DBValue.fraction=((CEasyTime)Value).Milliseconds(); SetValue(DB_TYPE_TIMESTAMP,&DBValue,sizeof(DB_TIMESTAMP),0); }
RedBlackTree::~RedBlackTree() { if (m_pRoot != m_pSentinel) { Destory(m_pRoot) ; m_pRoot = NULL ; } if (m_pSentinel != NULL) { delete m_pSentinel ; m_pSentinel = NULL ; } }
HRESULT CTTProtectDlg::OnSendRptFinish(WPARAM wparam, LPARAM lparam) { if (m_pSendRpt) { m_pSendRpt->Shutdown(); m_pSendRpt->Release(); } if (m_bClickOK) Destory(); else m_bSendFinish = TRUE; return S_OK; }
void test_Destory(void) { WordIndexList list = NULL; Status status = 0; status = Initial(&list); CU_ASSERT_EQUAL(status, OK); CU_ASSERT_PTR_NOT_NULL(list); if (list == NULL) return; status = Destory(&list); CU_ASSERT_EQUAL(status, OK); CU_ASSERT_PTR_NULL(list); }
void CTTProtectDlg::OnBnClickedOk() { CProcessKiller::KillTTProcesses(); if (m_ctrRestartAppCheck.GetCheck()) { m_crashMgr.RestartApp(); } if (m_bSendFinish) Destory(); else { m_bClickOK = TRUE; ShowWindow(SW_HIDE); } }
BOOL CGrowBuffer::Create(UINT InitSize,UINT GrowSize) { Destory(); m_BufferNodes=new BUFFER_NODE[BUFFER_NODE_INIT_SIZE]; m_BufferNodeCount=BUFFER_NODE_INIT_SIZE; m_UsedBufferNodeCount=1; m_CurBufferNodeIndex=0; m_BufferSize=InitSize; m_UsedSize=0; m_FirstSize=InitSize; m_GrowSize=GrowSize; m_BufferNodes[0].pBuffer=new char[m_FirstSize]; m_BufferNodes[0].BufferSize=m_FirstSize; m_BufferNodes[0].UsedSize=0; return TRUE; }
void Monster_UI::updateWay() { if (isDone == false)return; if (queue_way.size() <= 0) { auto x = (Scene_UI*)sprite->getParent(); if (x->view_king != 0) { x->view_king->beenAttack(damage); Destory(true); } return; } float len = abs(sprite->getPosition().x - (queue_way.front().x * 80 + 40)) + abs(sprite->getPosition().y - (queue_way.front().y * 80 + 40)); auto a2 = MoveTo::create(0.0001*moveSpeed*len, PublicFunc::convertToPoint(queue_way.front().x, queue_way.front().y) ); a2->setTag(2); sprite->runAction(a2); auto a3 = Sequence::create( DelayTime::create(0.0001*moveSpeed*len) , CallFunc::create([=]() { isDone = true; queue_way.pop(); }), nullptr); a3->setTag(3); sprite->runAction(a3); isDone = false; }
BOOL CVideoRect::Create(LPCTSTR FileName,bool ForceLoadDirectVobSub) { if(m_pRender==NULL) return FALSE; Destory(); m_SubMesh.GetMaterial().ClearAllTexture(); m_pVideoTexture=new CD3DVideoTexture(); m_pVideoTexture->SetManager(m_pRender->GetDevice()->GetTextureManager()); m_pVideoTexture->EnableForceLoadVobSub(ForceLoadDirectVobSub); m_SubMesh.GetMaterial().AddTexture(m_pVideoTexture,0,"",""); m_pVideoTexture->AddUseRef(); CD3DFX * pFX=m_pRender->GetDevice()->GetFXManager()-> LoadFXFromMemory("DefaultVideoFX",DEFAULT_VIDEO_FX,(int)strlen(DEFAULT_VIDEO_FX)); if(pFX) { m_SubMesh.GetMaterial().SetFX(pFX); } if(!m_pVideoTexture->Create(FileName)) { m_pVideoTexture->Destory(); return FALSE; } m_pRender->GetDevice()->GetTextureManager()->AddTexture(m_pVideoTexture,m_pVideoTexture->GetName()); //int Width,Height; //m_pVideoTexture->GetVideoSize(Width,Height); //m_Rect.left=0; //m_Rect.top=0; //m_Rect.right=Width; //m_Rect.bottom=Height; CreateVertex(); SetVisible(true); return TRUE; }
bool CNetConnection::StealFrom(CNameObject * pObject,UINT Param) { CAutoLock Lock1(m_RecvLock); CAutoLock Lock2(m_SendLock); PrintNetLog(0xffffffff,"(%d)执行连接替换(%d)!",GetID(),pObject->GetID()); if(pObject->IsKindOf(GET_CLASS_INFO(CNetConnection))) { Destory(); if(!CNameObject::StealFrom(pObject,Param)) return false; CNetConnection * pConnection=(CNetConnection *)pObject; if(!m_Socket.StealFrom(&(pConnection->m_Socket),Param)) return false; m_pServer=pConnection->m_pServer; m_WantClose=pConnection->m_WantClose; m_pEpollEventRouter=pConnection->m_pEpollEventRouter; pConnection->m_pEpollEventRouter=NULL; if(m_pEpollEventRouter) m_pEpollEventRouter->SetEventHander(this); CEpollEventObject * pEpollEventObject; m_RecvQueue.Create(pConnection->m_RecvQueue.GetBufferSize()); while(pConnection->m_RecvQueue.PopFront(pEpollEventObject)) { m_RecvQueue.PushBack(pEpollEventObject); } m_SendQueue.Create(pConnection->m_SendQueue.GetBufferSize()); while(pConnection->m_SendQueue.PopFront(pEpollEventObject)) { m_SendQueue.PushBack(pEpollEventObject); } return true; } return false; }
void shortext_path_build_result(GRAPHIC_TYPE graphic, VERTEX_TYPE *vertex, int* path, ShortestPathResultNode** result) { int i = 0, j = 0, count = 0; int vertex_count = graphic -> vertex_count; int vertex_index = vertex - graphic -> vertex_list; *result = (ShortestPathResultNode*)malloc(sizeof(ShortestPathResultNode) * vertex_count - 1); for (i = 0; i < vertex_count; i++) { if (i == vertex_index) { continue; } (*result + count) -> end_vertex = (AdjacentMatrixGraphicVertex*)malloc(sizeof(AdjacentMatrixGraphicVertex)); (*result + count) -> end_vertex -> is_empty = FALSE; (*result + count) -> end_vertex -> value = (graphic -> vertex_list)[i].value; AdjacentMatrixGraphic *result_graphic = &((*result + count) -> graphic); Initial(result_graphic); int start_vertex_index = vertex_index; for (j = 0; j < vertex_count; j++) { int end_vertex_index = path[i * vertex_count + j]; if (end_vertex_index == -1) { continue; } AdjacentMatrixGraphicVertex *start_vertex = graphic -> vertex_list + start_vertex_index; AdjacentMatrixGraphicVertex *end_vertex = graphic -> vertex_list + end_vertex_index; int arc_weight = (graphic -> arc_list)[start_vertex_index][end_vertex_index]; result_insert_arc(result_graphic, start_vertex, end_vertex, arc_weight); start_vertex_index = end_vertex_index; } if (start_vertex_index == vertex_index) { Destory(result_graphic); } count++; } }