hchdown 发表于 2008-8-12 17:02:00

[求助]vs2005+arx2007老报内存读,写错误????

<p>怎么原来arx2002下都很正常的代码,放到vs2005下就老报告内存错误??示例代码如下:</p><p>&nbsp;ArxDbgSelSet ss;<br/>&nbsp;ads_name ent,sset;<br/>&nbsp;ss.setAllowSingleOnly(true,false);<br/>&nbsp;AcDbObject openObj;<br/>&nbsp;if (ArxDbgSelSet::kSelected!=ss.userSelect(L"请选择绿框",NULL,acutBuildList(-4,L"&lt;AND",8,L"绿框",RTDXF0,L"LWPOLYLINE",-4,L"AND&gt;",RTNONE)))<br/>&nbsp;&nbsp;{</p><p>&nbsp;&nbsp;break;<br/>&nbsp;&nbsp;}<br/>&nbsp;ss.asAdsName(sset);<br/>&nbsp;acedSSName(sset, 0, ent);<br/>&nbsp;acdbGetObjectId(objId, ent);<br/>&nbsp;AcDbEntity* pEnt=(AcDbCurve*)openObj.Open(objId,AcDb::kForRead);<br/>&nbsp;struct resbuf * m_XData;=acutNewRb(AcDb::kDxfRegAppName);<br/>&nbsp;m_XData-&gt;resval.rstring = (TCHAR*) malloc(wcslen(L"sdfsdf") + 1);<br/>&nbsp;wcscpy(m_tmpXData-&gt;resval.rstring, L"sdfsdf");<br/>&nbsp;pEnt-&gt;setXData(m_XData);<br/>&nbsp;pEnt-&gt;setColorIndex(ArxDbgUtils::kBlue);<br/>&nbsp;if (NULL != m_XData)<br/>&nbsp;&nbsp;acutRelRb(m_XData);&nbsp;&nbsp;//就是这里,为什么释放了要报告什么00....5写错误,不释放的话又要报告0...4写错误<br/>&nbsp;}<br/>}</p><p></p><p>请各位高手帮忙!!!!为什么我释放和不释放都要报告内存写错误????</p>

sieben 发表于 2008-8-13 08:23:00

<p>好久没写C++,一下子反应不过来!</p><p>pEnt-&gt;setColorIndex(ArxDbgUtils::kBlue);</p><p>pEnt-&gt;close();//我建议你在这里加这一句试试,不敢肯定<br/>&nbsp;if (NULL != m_XData)</p>

smartCADD 发表于 2008-8-14 14:52:00

AcDbEntity* pEnt=(AcDbCurve*)openObj.Open(objId,AcDb::kForRead);//改成kForWrite<br/>&nbsp;struct resbuf * m_XData;=acutNewRb(AcDb::kDxfRegAppName);<br/>&nbsp;m_XData-&gt;resval.rstring = (TCHAR*) malloc(wcslen(L"sdfsdf") + 1);<br/>&nbsp;wcscpy(m_tmpXData-&gt;resval.rstring, L"sdfsdf");<br/>&nbsp;pEnt-&gt;setXData(m_XData);<br/>&nbsp;pEnt-&gt;setColorIndex(ArxDbgUtils::kBlue);<br/>//加上pEnt-&gt;close();
页: [1]
查看完整版本: [求助]vs2005+arx2007老报内存读,写错误????