TIdTCPServerExecute问题求助 |
尚未結案
|
biqiyun
一般會員 ![]() ![]() 發表:1 回覆:0 積分:0 註冊:2005-07-04 發送簡訊給我 |
我的代码如下:
class TPack { public: int nType; int nLen; BYTE *pData; __fastcall TPack() :nType(0), nLen(0), pData(NULL) { }; __fastcall ~TPack() { if (pData != NULL) delete []pData; }; }; void __fastcall TLmsForm::IdTCPServerExecute(TIdPeerThread *AThread) { TPack *pPack = new TPack; try { pPack->nType = AThread->Connection->ReadInteger(true); pPack->nLen = AThread->Connection->ReadInteger(true); if (pPack->nLen > 0) { pPack->pData = new BYTE[pPack->nLen]; AThread->Connection->ReadBuffer(pPack->pData, pPack->nLen); } } catch (...) { AThread->Connection->Disconnect(); if (pPack->pData != NULL) { delete [] pPack->pData; pPack->pData = NULL; } } if (pPack->pData == NULL) { delete pPack; return; } switch (pPack->nType) { case PACK_ADDGROUP: ParsePackAddGroup(pPack); Broadcast(pPack); break; case PACK_DELGROUP: ParsePackDelGroup(pPack); Broadcast(pPack); break; } delete pPack; }用BoundsChecker调试显示行 TPack *pPack = new TPack; 出错: Questionable use of thread Thread created using CreateThread rather than _beginthread 好像会发生内存泄漏,我对线程不是很熟悉,该怎样修改程序呢? 發表人 - biqiyun 於 2005/09/14 18:23:18 |
Ktop_Robot
站務副站長 ![]() ![]() 發表:0 回覆:3511 積分:0 註冊:2007-04-17 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |