[求助]vs2005+arx2007老报内存读,写错误????
<p>怎么原来arx2002下都很正常的代码,放到vs2005下就老报告内存错误??示例代码如下:</p><p> ArxDbgSelSet ss;<br/> ads_name ent,sset;<br/> ss.setAllowSingleOnly(true,false);<br/> AcDbObject openObj;<br/> if (ArxDbgSelSet::kSelected!=ss.userSelect(L"请选择绿框",NULL,acutBuildList(-4,L"<AND",8,L"绿框",RTDXF0,L"LWPOLYLINE",-4,L"AND>",RTNONE)))<br/> {</p><p> break;<br/> }<br/> ss.asAdsName(sset);<br/> acedSSName(sset, 0, ent);<br/> acdbGetObjectId(objId, ent);<br/> AcDbEntity* pEnt=(AcDbCurve*)openObj.Open(objId,AcDb::kForRead);<br/> struct resbuf * m_XData;=acutNewRb(AcDb::kDxfRegAppName);<br/> m_XData->resval.rstring = (TCHAR*) malloc(wcslen(L"sdfsdf") + 1);<br/> wcscpy(m_tmpXData->resval.rstring, L"sdfsdf");<br/> pEnt->setXData(m_XData);<br/> pEnt->setColorIndex(ArxDbgUtils::kBlue);<br/> if (NULL != m_XData)<br/> acutRelRb(m_XData); //就是这里,为什么释放了要报告什么00....5写错误,不释放的话又要报告0...4写错误<br/> }<br/>}</p><p></p><p>请各位高手帮忙!!!!为什么我释放和不释放都要报告内存写错误????</p> <p>好久没写C++,一下子反应不过来!</p><p>pEnt->setColorIndex(ArxDbgUtils::kBlue);</p><p>pEnt->close();//我建议你在这里加这一句试试,不敢肯定<br/> if (NULL != m_XData)</p> AcDbEntity* pEnt=(AcDbCurve*)openObj.Open(objId,AcDb::kForRead);//改成kForWrite<br/> struct resbuf * m_XData;=acutNewRb(AcDb::kDxfRegAppName);<br/> m_XData->resval.rstring = (TCHAR*) malloc(wcslen(L"sdfsdf") + 1);<br/> wcscpy(m_tmpXData->resval.rstring, L"sdfsdf");<br/> pEnt->setXData(m_XData);<br/> pEnt->setColorIndex(ArxDbgUtils::kBlue);<br/>//加上pEnt->close();
页:
[1]