读书人

收藏 不显示删除回复显示所有回复显示

发布时间: 2012-12-21 12:03:49 作者: rapoo

收藏 不显示删除回复显示所有回复显示星级回复显示得分回复 return 发生 access violation 错误
这是我的代码


{
boolean bresult = FALSE;
AECHAR wMaoHao = ':';
AECHAR* waddress;
AECHAR* ptemp = NULL;
AECHAR* ptemp2 = accessAddress;
char* pstrtemp;
uint16 uport = 0;

ptemp = WSTRCHR(accessAddress, wMaoHao);

if (!ptemp)
{
*pwaddress = NULL;
*pwport = NULL;
return;
}

waddress = (AECHAR *) MALLOC( sizeof(AECHAR) * (ptemp - accessAddress + 1) );
if (waddress)
{
AECHAR * pa1 = waddress;
while(ptemp2 != ptemp)
{
*waddress = *ptemp2;
++ waddress;
++ ptemp2;
}
if (ptemp2 == ptemp)
{
*waddress = 0;
}

waddress = pa1;
}

pstrtemp = (char *) MALLOC( sizeof(char) * WSTRLEN( ++ptemp ) + 1 );
if (pstrtemp)
{
WSTRTOSTR(ptemp, pstrtemp, sizeof(char) * WSTRLEN( ptemp ) + 1);
uport = ATOI(pstrtemp);
}

*pwaddress = waddress;
*pwport = uport;



}



为何 一到 return 就产生 access violation ?
我用的是VC6.0
以前运行这个函数的时候也不会出现这样的错误的。但是现在出现了这个错误,这是什么原因呢?
[解决办法]
自己顶一下

我在单步调试的时候


if (!ptemp)
{
*pwaddress = NULL;
*pwport = NULL;
return;
}


在判断ptemp都报ACCESS VIOLATION 错误。
我就不明白了。
是不是我的VC6.0有错误。还是模拟器有错误了

请高手指教!

读书人网 >Brew

热点推荐